Search code examples
javajunitsuite

Why does a JUnit suite class not execute its own Test, Before, and After annotations?


Why does a JUnit Suite class, in my cases its called TestSuite.class, not execute its own Test, Before, and After annotations? It only exectutes its own BeforeClass, AfterClass, and then ALL annotations of the suite test classes. I proved this is the case by creating a test project around this theory: https://gist.github.com/djangofan/5033350

Can anyone refer me to where this is explained? I need to really understand this.


Solution

  • Because a TestSuite is not a Test itself. Those annotation are for unit tests only. See here for an example.

    public class FeatureTestSuite {
      // the class remains empty <----- important for your question
    }