Showing posts with label junit. Show all posts
Showing posts with label junit. Show all posts

Saturday, August 17, 2013

Wednesday, June 20, 2012

How to ignore a class in JUnit tests

You may need to ignore a whole class in a test folder, or just a single test in a test case. To do it you should use @Ignore annotation.

This is how you should import it:


To ignore a whole class just add @Ignore annotation to it:

If you do it none of the tests in the ignored class will be called by JUnit. Optionaly you can add a text comment to an ignore annotation:

If you want to ignore only a single test you should write:

or alternatively with text comment:

The other way to ignore a test is to remove @Test annotation. But if you add @Ignore annotation to your test method, JUnit will report that some methods in your test set were ignored and this can be used as a remainder to fix it later.

That's all.
Good luck.