-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to deal with assert.expect( 0 )? #31
Comments
Why do we need to run unit tests with assertions disabled? |
It may be unnecessary to run unit tests with assertions disabled. Is there a class of errors that only manifests when assertions are off? If so, is it a frequent enough kind of error that we need to run tests with assertions disabled? |
The only one I can think of is failure to use |
The proposal to only run unit tests with assertions enabled sounds reasonable to me, but I want to run it past @jonathanolson before we proceed. |
If you must use this pattern: if ( !window.assert ) {
assert.expect( n );
} ... then you shouldn't be assuming that there are n tests that don't involve assert.expect( numberOfTestsRun ); And yes, that sounds like a colossal error-prone pain. |
If we do decide to run tests with assertions enabled, then tests should verify that |
We are also planning to run unit tests on compiled code, where assertions cannot be enabled. |
Presumably only for scenery/kite/dot, not the simulations/runnables? |
I'm getting confused. In this thread: #28 (comment)
Did you mean "We will only skip scenery/kite/dot and will continue to test built sims, since we see issues there"? |
I'm removing the call to Chris Malley [10:27 AM] Sam Reid [10:29 AM] Chris Malley [10:29 AM] Sam Reid [10:29 AM] Chris Malley [10:29 AM] Sam Reid [10:29 AM] |
Sam Reid [10:31 AM] Chris Malley [10:32 AM] |
|
@jonathanolson I assume that this is also unnecessary in TrailTests.js: 680 // this may change if for some reason we end up calling more events in the future
681 assert.expect( 4 ); OK to remove it? |
In TrailTests.js the |
Mind if I replace all |
@pixelzoom gave me the go-ahead on slack |
I replaced |
@pixelzoom can I create a scenery issue for #31 (comment) and close this issue? |
I created phetsims/scenery#720, closing. |
In #30 we discussed
assert.expect
. Here's a case where it's used and currently necessary:When assertions are enabled, two tests are run (the assert.throws calls). When assertions are disabled, 0 tests are run. If the
assert.expect
was commented out, QUnit would report a failure with this message:Two solutions for dealing with this problem are:
assert.expect(0)
as we have beenassert.ok( c.value, 'boolean value should be true' );
which runs whether assertions are enabled or not.(1) would fail if we add a test like (2). But (2) seems like a bit of a workaround to deal with QUnit expecting at least one test by default. @pixelzoom which do you recommend?
The text was updated successfully, but these errors were encountered: