Run all tests in Junit 4

前端 未结 7 1608
感动是毒
感动是毒 2021-02-01 15:45

I want to be able to run all tests in a project programmatically. I know Eclipse has a \"Run as JUnit test\" configuration which somehow grabs all the tests in a project and run

7条回答
  •  没有蜡笔的小新
    2021-02-01 16:17

    Of the top of my head using Spring:

    • Implement a TypeFilter that matches classes with methods annotated with @Test (don't forget to consider the superclasses)
    • Invoke classpath scanning on your top-most test package
    • Invoke the JUnitRunner with the scan results

    More info on classpath scanning and custom type filters here

提交回复
热议问题