mercredi 24 juin 2015

Use class from test scope in other module

I have a module as part of a framework that provides common features to other modules. I have created a class (UtilitiesForTesting) that provides some utils to be used only in my tests, so it's stored in test section of the module.

The module has the following structure:

project
    -src
       -main
         -java
           -com
             -company
               -product
                 +Foo
       -test
         -java
           -com
             -company
               -product
                 +FooTest
               -utility
                 +UtilitiesForTesting

UtilitiesForTesting class is visible inside the project but when I compile it the resulting jar does not contains any test class.

Now I want to use the modules in other modules, because I need this common functionality, but also I want to use testing utilities.

I don't want to place UtilitiesForTesting in the /main section, since I don't want to allow the use of this class in production code, only in test.

I want to have just a module that provides production classes to other module and test util to the same module, but restricting using the test utilities in the /main section.

Is there any way to use a class of the test scope of a module in other module?

Aucun commentaire:

Enregistrer un commentaire