vendredi 30 octobre 2015

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

With JUnit, the description of my test cases would normally in the method name, like:

@Test
public void should_return_6_if_distance_is_2km() {
}

or

@Test
public void shouldReturn6IfDistanceIs2km() {
}

Which is not quite readable.

But with the testing frameworks of other lanuage, like javascript, or scala, I can use:

describe("Taximeter") {
    it("should return 6 if the distance is 2km") {
        ...
    }
}

which is more readable with plain strings.

Is it possible to do this in Java?

Aucun commentaire:

Enregistrer un commentaire