testing - How can I use strings to describe test cases in Java? -


with junit, description of test cases in method name, like:

@test public void should_return_6_if_distance_is_2km() { } 

or

@test public void shouldreturn6ifdistanceis2km() { } 

which not quite readable.

but testing frameworks of other lanuage, javascript, or scala, can use:

describe("taximeter") {     it("should return 6 if distance 2km") {         ...     } } 

which more readable plain strings.

is possible in java?

using assertion framework, hamcrest, assertj or truth automatically result in better error messages @ least. , of course, assertions more readable using asserttrue, assertequals, etc.

for example, assertj:

assertthat( myvar ).describedas( "myvar" ).isequalto( 6 ); 

this result in error message (if myvar != 6) includes name "myvar", expected value , real value.


Comments

Popular posts from this blog

matlab - error with cyclic autocorrelation function -

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

c# - What is a good .Net RefEdit control to use with ExcelDna? -