Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

@Test equivalent on Junit 3?

 
Akhilesh Trivedi
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use annotation


to control which tests to be executed on Junit4.

For some reason, I have to be on java 1.4 and hence I am restricted on JUnit 3.

How do I have the above control as handy in JUnit 3, because on 1.4 annotations are not supported.
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From what I remember any method that started with the test prefix was considered a test method. Example:

 
Akhilesh Trivedi
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's right.

But I am talking about when we have more than one test method and we selectively want to run one/some of them.

On Junit 4


will run both testMethod1() and testMethod2()

And


will run only testMethod1().




In above case it will run only testMethod2().


How to achieve this control with ease on JUnit3.
 
E Armitage
Rancher
Posts: 989
9
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Changing the method name from testXXX to atestXXX could be viewed as just as easy as commenting out an annotation.
 
Junilu Lacar
Bartender
Pie
Posts: 7768
62
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aside from renaming your test methods, you can create a TestSuite that only includes the tests you want to run.

BTW, in JUnit4, use the @Ignore annotation to temporarily disable a test instead of commenting out the @Test annotation

When you use the @Ignore annotation, JUnit will report that there are ignored tests. If you just comment out the @Test annotation, JUnit will not say anything and it's easy to forget to uncomment later.
 
Akhilesh Trivedi
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Junilu Lacar wrote:Aside from renaming your test methods, you can create a TestSuite that only includes the tests you want to run.


Any references?
 
Junilu Lacar
Bartender
Pie
Posts: 7768
62
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Akhilesh Trivedi wrote:Any references?

Any search engines? SearchFirst - JUnit 3 testsuite examples should turn up something
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic