wood burning stoves 2.0*
The moose likes Testing and the fly likes @Test equivalent on Junit 3? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "@Test equivalent on Junit 3?" Watch "@Test equivalent on Junit 3?" New topic
Author

@Test equivalent on Junit 3?

Akhilesh Trivedi
Ranch Hand

Joined: Jun 22, 2005
Posts: 1511
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.


Keep Smiling Always — My life is smoother when running silent. -paul
[FAQs] [Certification Guides] [The Linux Documentation Project]
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9343
    
111

From what I remember any method that started with the test prefix was considered a test method. Example:



[My Blog] [JavaRanch Journal]
Akhilesh Trivedi
Ranch Hand

Joined: Jun 22, 2005
Posts: 1511
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

Joined: Mar 17, 2012
Posts: 761
    
    9
Changing the method name from testXXX to atestXXX could be viewed as just as easy as commenting out an annotation.
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4419
    
    5

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.


Junilu - [How to Ask Questions] [How to Answer Questions]
Akhilesh Trivedi
Ranch Hand

Joined: Jun 22, 2005
Posts: 1511
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

Joined: Feb 26, 2001
Posts: 4419
    
    5

Akhilesh Trivedi wrote:Any references?

Any search engines? SearchFirst - JUnit 3 testsuite examples should turn up something
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: @Test equivalent on Junit 3?
 
Similar Threads
regarding junit
SQL & JUnit
JUnit - Testing someone elses code
pros & cons of JUnit
Spring 3 MVC jUnit testing with bindingresult