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
Post a Comment