Menu

Stopping a test when a thred fails.

Help
jabadia
2009-11-01
2018-01-17
  • jabadia

    jabadia - 2009-11-01

    Hello,

    I might have seen this sort of question in the forum, but I did not see any
    clear answer.

    Lets assume I have a ping thread to a server , and the main thread that does
    something else for ever.

    I would like the main thread ( = the entire test ) to fail/stop in case of a
    failure on the ping thread.

    I know that I can report a failure via the monitor thread, but the main will
    continue forever.

    Is there a way to generate some sort of an Event and catch it then stop the
    test ?

    Is there another way? ( I saw the yes/no J option ion window )

    Thanks,

    Yossi.

     
  • Golan Derazon

    Golan Derazon - 2009-11-05

    Here is a possible solution, I haven't tried it, but it should work.

    In your thread activate this code:

    if (ListenerstManager.getInstance() instanceof ListenerstManager) {

    ((ListenerstManager)ListenerstManager.getInstance()).gracefulStop();


    }

    Pay attention to the following limitations:

    1. This code will only work when activating test from the runner. (it will not run when running test from eclipse)
    2. The more problematic issue: after the code above is activated, execution will stop in the next time the test makes a report (report.report(...)), so you need to embed report calls in your test code.
     
  • jabadia

    jabadia - 2009-11-06

    Thanks Golan,

    I'll give it a try.

    /Yossi.

     
  • Nir Ben Yair

    Nir Ben Yair - 2018-01-17

    When running from maven the provided solution doesn't work.
    Is there any solution?

     

Log in to post a comment.

MongoDB Logo MongoDB