Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

@After annotation of Junit  RSS feed

 
Buddhika Mawella
Ranch Hand
Posts: 40
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am new to Junit and trying to execute following test. What I have understood is that if a method of a Junit test case is annotated with @After,
that method should run after every test method. I created below test class with Junit and it only print "inside @Test" when running. But according to my knowledge that should print both "inside @Test" and "inside @After". So whats wrong with this? help me.


Thanks.
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36441
454
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Buddhika,
Since you are extending TestCase, JUnit is treating it as a JUnit 3.8 test. Which looks for setUp/tearDown/test* named methods.

If you remove the "extends TestCase", JUnit will see it as a JUnit 4 test and do what you expect.
 
Buddhika Mawella
Ranch Hand
Posts: 40
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jeanne. Got it.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!