How to find unit tests are not part of any kit?

With JUnit 3, if you forget to add a test to the package, it will not run. How can I find all JUnit test cases that are not part of our top-level package, or any collection that it contains recursively?

+3
source share
4 answers

Using the UCDetector , you should be able to identify unused public classes (which include unused test cases) from Eclipse.

+1
source

- ant junit (, match * Test.java).

junit * Test.java . , ant manual.

<junit printsummary="yes" haltonfailure="yes">
  <classpath>
    <pathelement location="${build.tests}"/>
    <pathelement path="${java.class.path}"/>
  </classpath>

  <formatter type="plain"/>

  <batchtest fork="yes" todir="${reports.tests}">
    <fileset dir="${src.tests}">
      <include name="**/*Test*.java"/>
      <exclude name="**/AllTests.java"/>
    </fileset>
  </batchtest>
</junit>
+1

, , , , TestCase ( , clazz = Class.forName(), Test.isAssignableFrom(clazz) .

( - , , , ).

, . , , , , , , .

, JUnit4, .

, ( , JUnit ) - , ( Test), Ant , .

+1

Code coverage that includes your test suite will pick up any test classes that fail

+1
source

Source: https://habr.com/ru/post/1705337/


All Articles