Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Excluding JUnit tests in eclipse

Tags:

java

Hey
I have a whole bunch of unit tests. I have placed them into suitable test suites. I would like to be able to click on the root directory and go run JUnit tests to execute all the tests. However, if I do this it runs all the tests AND then runs the testsuites. Therefore running all the tests again.

Is there someway to exclude the testsuites in Eclipse? thanks

like image 445
Roger Avatar asked Dec 16 '10 14:12

Roger


People also ask

How to get started with JUnit in Eclipse?

The JUnit view in Eclipse allows you to run test class or test methods again, by right clicking on the test class or a test method, and click Run. In case of failure, you can copy the exception stack trace by right click on the test class or a test method, and click Copy Failure List: That’s how to get started with JUnit in Eclipse.

How do I see the result of a JUnit test?

To see the result of a JUnit test, Eclipse uses the JUnit view which shows the results of the tests. You can also select individual unit tests in this view, right-click on them and select Run to execute them again. Eclipse creates run configurations for tests. You can see and modify these via the Run Run Configurations…​ menu.

Can I skip some test cases in JUnit?

It’s not about skipping test cases but it’s about excluding test cases for a particular package. Situations may arise when you want to exclude some Junit test cases from running in some environments (for example, uat, prod, etc.) while you are building your Java based application using gradle or maven build tool.

What is the best IDE for JUnit testing in Java?

JUnit is supported by almost any Java IDEs and build tools, thus it is the default choice of programmers to test their code.Eclipse has very good support for JUnit - the IDE is shipped with JUnit as its default testing library.


1 Answers

When you right click on the project directory and Run As > JUnit test it's basically the relevant run configuration that is being triggered. Therefore go to Run > Run Configurations and on the left panel see exactly what your JUnit configuration is actually doing and configure accordingly.

like image 193
dimitrisli Avatar answered Sep 20 '22 22:09

dimitrisli