JUnit Reports — Test Method Descriptions

后端 未结 4 873
盖世英雄少女心
盖世英雄少女心 2021-02-05 04:03

I am trying to see if there is a way to include \"descriptive text\" in my junit reports by way of javadocs. JUnit 4 doesnt seem to support the \'description\' attribute for the

4条回答
  •  无人及你
    2021-02-05 04:54

    I could imagine, that the Framework for Integrated Tests (FIT) would be a nice and clean solution.

    What does FIT do?
    FIT is a framework that allows to write tests via a table in a Word document, a wiki table or an html table.
    Every character outside of a table is ignored by FIT and let you enter documentation, description, requirements and so on.

    How does on of these tables look like?

    Imagine a function MyMath.square(int) that squares it's input parameter. You have to build a so called Fixture, being an adapter between your MyMath and the following table:

    class.with.Fixture.Square
    x    square()
    2    4
    5    25
    

    The first column describes input values, the second the expected result. If it's not equal, this field is marked as red.

    How does a Fixture look like?
    For the given example, this would be the correct fixture:

    package class.with.Fixture // Must be the same as in the fist row of the table
    
    public class Square extends Fixture {
        public int x; // Must be the same as in the second row
        public int square() { // Must be the same as in the second row
            return MyMath.square(x);
        }
    }
    

    Probably, you can use FIT for your requirements.
    Feel free to comment my answer or edit your question for more information!

提交回复
热议问题