Using JUnit @Rule in an Eclipse JUnit runner

Eclipse 3.7.2

I just implemented @Rulesome JUnit 4 tests, but when I run them in Eclipse, the methods are MethodRulenot called. It, like the Eclipse tester, does not recognize implementations @Ruleand does nothing special with fields that are annotated using @Rule.

I even tried using the "Standard" MethodRule, for example org.junit.rules.TestName, but it does not work properly (test names do not populate in the instance). Even the sample test in JavaDoc TestNamedoes not work when run in Eclipse.

Is there any trick? Eclipse just doesn't support JUnit Rules ?

+3
source share
2 answers

, - "" JAR , . JAR , , JUnit! , JAR - , our_runtime_library.jar, , ( ) JUnit, Spring, , . Unit Test Eclipse JUnit JAR ( - , ), (Eclipse), .

; , , 50 .

+4

, , Eclipse ( JUnit 4.8). , .

, JavaDoc : Note that MethodRule is now deprecated, you should be using TestRule instead.

+2

All Articles