简体   繁体   中英

How to get test results of multiple test classes ,after all tests run using Junit

I have 5 test classes and each testclasses include 2 @Test

example:

    class1:
    @Test
    public void c1_test1(){
    //...
    }
    @Test
    public void c1_test2(){
    //...
    }

    class2:
    @Test
    public void c2_test1(){
    //...
    }
    @Test
    public void c2_test2(){
    //...
    }
    ...

I want to get tests result after all Test Suite(All test classes) run Such As:

Class1: c1_test1 : failed Class1: c1_test2 : success

Class2: c2_test1 : failed class2: c2_test2 : success

tried RunListener class but I got results after test level,but how to get results after suite level. Is it possible in Junit?

Its possible to implement a listener in a way that it will store the results in some "predefined" file or series of files so that after all the tests will be done the result will appear in a file.

Another option is to use the output of the build tool, for example in maven, when you work with surefire/failsafe plugins it produces a "surefire-reports" where the same information is accessible. If you use it - check the "target" folder.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM