John Russell
John Russell

Reputation: 846

How can create a Junit4 Suite with Groovy?

I have

@RunWith(Suite.class)
 @Suite.SuiteClasses( [ 
     First.class,Second.class
 ])
 public class MySuite{

}

But eclipse doesn't give me a "Run As Junit4 Test". All the individual test classes work fine with GUnit, the groovy unit test runner built into eclipse.

Any thoughts?

Upvotes: 2

Views: 1854

Answers (2)

chanwit
chanwit

Reputation: 3214

@Suite.SuiteClasses accepts Class[] as its parameter.

You may try:

 @RunWith(Suite.class)
 @Suite.SuiteClasses([First.class, Second.class] as Class[])
 public class MySuite {

 }

Upvotes: 1

John Russell
John Russell

Reputation: 846

The only way I found to do this was to create a java class with a @Suite.SuiteClasses annotation as usual. You can put in the .class names of the Groovy classes you have for tests and it works well.

Kind of lame if you don't already have some java code to do it this way but I had a mix of Java and Groovy so it wasn't as big a deal.

The other option is to not use Suites at all and to use name patterns to find and run tests. Both ant and maven support this sort of pattern matching. I find it much easier than making sure I keep the suites up to date and Eclipse can just run all tests in a package if I want to do that.

Thanks for the help.

Upvotes: 1

Related Questions