0

I am currently learning JUnit. I came across two ways of passing multiple classes into runClasses method, ie. with @SuitClasses annotation and with an Array of classes.

@RunWith(Suite.class)               
@SuiteClasses({MyClass1.class,MyClass2.class})  
public class MySuiteClass {}

...

Result result = JUnitCore.runClasses(MySuiteClass.class);
Class<?>[] carr = {MyClass1.class,MyClass2.class};
Result result = JUnitCore.runClasses(carr);

Is there any difference between both methods and when should I be using either of them?

1 Answer 1

1

They're equivalent. However, you're probably best off not doing this at all. Most folks use a build tool (mvn or gradle usually) and have that run the tests automatically. That way you don't need to maintain a list of all the test classes you want to run.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.