File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Testing and the fly likes Excluding methods from a test case Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Excluding methods from a test case" Watch "Excluding methods from a test case" New topic
Author

Excluding methods from a test case

Shameer Kunjumohamed
Greenhorn

Joined: Sep 29, 2004
Posts: 12
Hi, can anybody tell me how can I exclude some methods in a TestCase ? My understanding is that, All the other methods in a TestCase except setup, tearDown and suite will be called as tests by the framework.

Thanks in advance.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24184
    
  34

If you're letting JUnit collect the tests from a class, it will only collect those with no arguments with a name like testXXX (for any value of XXX).


[Jess in Action][AskingGoodQuestions]
Shameer Kunjumohamed
Greenhorn

Joined: Sep 29, 2004
Posts: 12
Thank you Freind
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Ernest Friedman-Hill:
If you're letting JUnit collect the tests from a class, it will only collect those with no arguments with a name like testXXX (for any value of XXX).


I think they also need to have "void" as return type.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
And they must be public.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
I had to check...

SimpleTestCollector and ClassPathTestCollector apply the following rule to determine whether to execute the given class as a JUnit TestCase:

while the LoadingTestCollector also looks at the access modifiers and interface before attempting to execute the class:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Excluding methods from a test case