Get help with testing, discuss unit testing strategies etc.


Post by jflowers45 »

When I call t.fail() within a subtest, it seems to try to continue to execute the rest of the subtest.

When I call t.exit() from within a subtest, it halts execution of the entire test.

In one particular case I'd like to be able to call a failure that exits the current subtest and moves on to the next subtest. Is there any method for that?

Thanks as always.

-Joe

Post by nickolay »

Made a quick experiment, it seems to continue to the next "it" after "exit()":
StartTest(function(t) {

    t.it("Quix", function (t) {

        t.chain(
            { click     : [ 1, 1 ] },

            function (next) {
                t.exit()

                next()
            },
            function (next) {
                t.diag("SHOULD NOT BE VISIBLE")

                next()
            }
        )
    })


    t.it("Foo", function (t) {

        t.diag("Bar")
    })
})
Can you change the code above to demo the problem?

Post by jflowers45 »

Thanks as usual Nikolay! I can confirm that your code behaves as I was hoping. I had assumed that exit() was actually supposed to get out of subtests but I'm glad to see it isn't.

Oddly enough, in this very specific instance the test runner behaves differently for me in my windows 7 64 bit vm (only on Google Chrome - Firefox works fine) than it does on my windows 10 machine. However, the dumbed down test doesn't display the discrepancy ... so there's really nothing for me to share at the moment. Now that I know the expected behavior I'll use that, and if I'm able to find a concrete issue I'll let you know.

Thanks!
-Joe

Post by nickolay »

Sure, yw

Post by jflowers45 »

BTW I realized the reason I was seeing different behavior on one VM from another ... I had checked the "break on fail" in the UI without remembering. (smacks forehead!!!)

Post by nickolay »

:)

Post Reply