Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Eclipse to jump to failed JUnit test when test is not a Java method

Tags:

I've got a nive bridge that allows me to run JBehave tests through JUnit with deeper integration than out of the box from JBehave - my JUnit hierarchy now shows each story file and the scenarios under it so you can see which scenarios have failed. This is all working well, except that you can't double-click on a failed sceanrio in Eclipse and get it to jump to the relevant line in the story file.

The JUnit Description class is designed around tests being Java methods, but I was wondering if there was some cunning way of indicating the location to make this work (e.g. in the annotations list).

Thanks.

like image 897
t0rx Avatar asked Nov 20 '10 18:11

t0rx


People also ask

How do you're run failed test cases in JUnit?

Rerun Failed Tests with JUnit 4 ExampleWe need two classes, one of them is our Rule Class's RetryRule and the other is our Test Class's RetryRuleTest. In RetryRuleTest class, I will open www.swtestacademy.com and get its title and check it with the WRONG expected title.

Which view in Eclipse can be used to navigate through all the failed JUnit tests?

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.

How do I set JUnit to default in Eclipse?

The steps are as below: Project > Properties > Java Build Path > Libraries. Click "Add External JARs..." button at right side --> Select your preferred JUnit jar. Click OK button.


1 Answers

I think most Java IDEs actually react to the message or stack trace given when a JUnit test fails. For example in IntelliJ, failure lines are highlighted and clickable so long as they have SomeFileTheIDEKnows.java:123.

Can you get a stack trace or failure message to show that when a JUnit test fails?

like image 148
Freiheit Avatar answered Sep 26 '22 09:09

Freiheit