Test not marking as failed

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Test not marking as failed

jefferson
Hi,

I have the following code block in my nGrinder script. It's supposed to mark the test as failed when an exception occurs BUT I do not see see the errors being reflected in the nGrinder console during the test.

        try{
            xmppClient.connect();
            xmppClient2.connect();
        }
        catch (NoResponseException e){
            grinder.statistics.forLastTest.success = 0;
        }
        catch (AuthenticationException e){
            grinder.statistics.forLastTest.success = 0;
        }

When I checked the agent logs, I can see a lot of these messages. I expect them to be treated as ERRORS during the run.

agentorange-9.log:net.grinder.script.InvalidContextException: No tests have been performed by this thread.
agentorange-9.log:net.grinder.script.InvalidContextException: No tests have been performed by this thread.
agentorange-9.log:net.grinder.script.InvalidContextException: No tests have been performed by this thread.
agentorange-9.log:net.grinder.script.InvalidContextException: No tests have been performed by this thread.
Reply | Threaded
Open this post in threaded view
|

Re: Test not marking as failed

junoyoon
Administrator
it seems you didn't record appropriate method... using test.record("method_name")

Could u post the whole script...?
Reply | Threaded
Open this post in threaded view
|

Re: Test not marking as failed

jefferson
This post was updated on .
    @BeforeThread
    public void beforeThread() {
       test.record(this,"sendMessage")
        grinder.logger.info("before thread.")

    }

    @Test
    public void test() {
        if(connectFlag == 0){
            configureConnection();

        }

        cdl = new CountDownLatch(2);
        sendTime = System.currentTimeMillis();
        sendMessage();
        elapsedTime = System.currentTimeMillis() - sendTime;
        nextRand = 1000 * (randomno.nextGaussian() * STANDARD_DEVIATION + PACING_TIME);
        sleepTime = (long) (nextRand - elapsedTime);
        //grinder.logger.info(String.format("Sleeping for %dms", sleepTime));
        grinder.sleep(sleepTime);
    }



public void configureConnection() {
        try{
            xmppClient.connect();
            xmppClient2.connect();
            xmppClient.login(sender.getUserId(), assertion);
            xmppClient2.login(receiver.getUserId(), assertion2);
        }
        catch (NoResponseException e){
            grinder.statistics.forLastTest.success = 0;
        }
        catch (AuthenticationException e){
            grinder.statistics.forLastTest.success = 0;
        }
}