ceylon.test.TestRunner fails when tests fails -


whenever test function (a function annotated test) contains assertions fail, assertion has same effect when trowing exception: no further code lines in function executed. thus, assert statements in functions annotated 'test' works ordinary assert statements in ordinary ceylon functions. runs contrary documentation, states ordinary assert statements can used making unit tests.

thus, running code below, see statement mytests1 not ´mytests2`:

import ceylon.test {     test, testrunner, createtestrunner }  test mytests1 () {     // assert true!     assert(40 + 2 == 42);     print("mytests1");     return null; }  test void mytests2 () {     // assert false!     assert(2 + 2 == 54);     print("mytests2"); }   "run module `tests`." shared void run() {      print("reached run function");      testrunner mytestrunner = createtestrunner(         [`function mytests1`, `function mytests2`]);      mytestrunner.run(); } 

this actual output:

"c:\program files\java\jdk1.8.0_121\bin\java" -dceylon.system.repo=c:\users\jon\.ideaic2017.2\config\plugins\ceylonidea\classes\embeddeddist\repo "-javaagent:c:\program files\jetbrains\intellij idea community edition 2017.2.1\lib\idea_rt.jar=56393:c:\program files\jetbrains\intellij idea community edition 2017.2.1\bin" -dfile.encoding=windows-1252 -classpath c:\users\jon\.ideaic2017.2\config\plugins\ceylonidea\classes\embeddeddist\lib\ceylon-bootstrap.jar com.redhat.ceylon.launcher.bootstrap run --run run tests/1.0.0 reached run function mytests1  process finished exit code 0 

this working intended – replacing asserts assertequals’ has same effect , prints same output, because both same thing: throw exception if assertion fails.

all test frameworks i’m aware of behave same way in situation: assertion failure results in exception , terminates execution of test method. design, since don’t know program once 1 expectation violated – rest of method might depend on assertion holding true, , might break in unpredictable , confusing ways.

if you’re writing tests like

test shared void testtwothings() {     assertequals { expected = 42; actual = 40 + 2; };     assertequals { expected = 42; actual = 6 * 9; } } 

you’re supposed write 2 tests instead.


Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -