4

Is it possible to configure in maven plugin,for which classes (like include/exclude by name pattern) JUNIT tests should be generated?

As i don't need tests for every class.

I managed to do it with command line but I need to do it in maven.

yuris
  • 1,109
  • 4
  • 19
  • 33

1 Answers1

4

It isn't possible to do that, but you can use the -Dcuts and -DcutsFile command line arguments to generate test classes for 1..N classes.

Writing a small class that generates the class names for a given package structure is pretty trivial. You can then use the results to create a comma-delimited string that can be pasted into the file you associate with the -DcutsFile argument, e.g.:

mvn evosuite:generate evosuite:export -DcutsFile=c:\temp\cutsFile.txt

Where the contents of cutsFile.txt are:

com.foo.A, com.foo.B

Another way to generate the list of testable classes is to run the EvoSuite jar from the command line with the -listClasses and -target parameters and pipe the output to a file (Windows example below):

java -jar c:\evosuite\evosuite-master-1.0.5.jar -listClasses -target target/classes > c:temp\testableClasses.txt

From there you can just pick and choose the classes you'd want to add to the CUTs file or add them to the command line using the -Dcuts command line argument.

user6629913
  • 180
  • 1
  • 14