javamavenautomated-teststest-framework

Where on a Maven build should a test framework reside - src/test/java or src/main/java?


I understand from the previous answers on this site that, for Maven builds:

  1. src/main/java will be deployed to production whereas src/test/java will not be.
  2. src/main/java contains the main application whereas src/test/java will contain code to test the main app

Now my question is, when writing a test framework, which approach is better/worse:

  1. Test framework itself will be the main app - hence it will reside on src/main/java?
  2. Test framework will only be used to test the main app - hence will reside on src/main/java?

Somehow getting stuck on visualizing this properly -

Any suggestions on this would be helpful.


Solution

  • I think you're going astray with

    1. src/main/java will be deployed to production whereas src/test/java will not be.

    I would rephrase it as

    1. src/main/java contains the code that consumers of the module will use (it is the purpose of your module)

    (This assumes that you build the testing framework as a separate module)

    If you need real life examples, you don't need to look any further than JUnit (the legendary testing framework)

    Prefer to work with TestNG? The code for TestNG is in a submodule "core", but even then: