Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a general way to mark a JUnit test as pending?

Tags:

Before stepping into the TDD cycle, I like to sketch out the tests that need to be implemented - i.e. write empty test methods with speaking names.

Unfortunately I have not found a way to "paint them yellow" - mark them as pending for JUnit. I can make them either fail or pass. Now I am letting them fail by throwing an Exception, but I'd rather use an equivalent of pending from rspec.

Is there such an option in JUnit or an "adjacent" library?

like image 481
kostja Avatar asked Jan 15 '13 15:01

kostja


People also ask

What are pending tests in TDD?

When tests are run at the command line with SBT, pending lines are printed in a yellow(ish) color. Marking tests as pending helps support the TDD style, and it's a convenient way of saying, “I need to write this test and implement the code behind it, but I haven't gotten there yet.”

Which of the given annotation can be used to mark test as unit test?

A JUnit test is a method contained in a class which is only used for testing. This is called a Test class. To mark a method as a test method, annotate it with the @Test annotation. This method executes the code under test.

How do you ignore a unit test?

If you want to ignore a test method, use @Ignore along with @Test annotation. If you want to ignore all the tests of class, use @Ignore annotation at the class level.

How do you stop a JUnit test?

You press the 'Stop JUnit test run' wanting to halt the execution immediately. And it doesn't! Then you must go to the Debug view (why that name? i'm not debugging, i'm running) and 'Terminate' it from there.


1 Answers

You can use @Ignore to ignore the test,

or this library to introduce the @PendingImplementation annotation:

https://github.com/ttsui/pending

I don't think there are other ways to achieve this..

like image 165
Enrichman Avatar answered Nov 06 '22 04:11

Enrichman