Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » JUNIT Testing(Necessarity of the constructor)
JUNIT Testing [message #837819] Fri, 06 April 2012 06:11 Go to next message
Jeffson Jeffson is currently offline Jeffson JeffsonFriend
Messages: 1
Registered: April 2012
Junior Member
Hi,

Normally, a class, which extends the "TestCase" class has to contain a constructor, which takes a String. The String then has to contain the names of the test-methods in your "TestCase"-class, which you want Junit to execute. But in eclipse you either:
1. Don't use any constructor, but it nevertheless works fine and all test-methods are executed.
or
2. Use a constructor, which takes a String. But you don't have to instantiate the test-class and it nevertheless works, even though you don't pass any String, you just push the "execute" button and it all magically works..

Can someone explain that, please?

Best regards
Re: JUNIT Testing [message #869807 is a reply to message #837819] Fri, 04 May 2012 11:22 Go to previous message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
On 06.04.2012 08:11, Jeffson Jeffson wrote:
> Hi,
>
> Normally, a class, which extends the "TestCase" class has to contain a
> constructor, which takes a String. The String then has to contain the
> names of the test-methods in your "TestCase"-class, which you want
> Junit to execute. But in eclipse you either:
> 1. Don't use any constructor, but it nevertheless works fine and all
> test-methods are executed.
> or
> 2. Use a constructor, which takes a String. But you don't have to
> instantiate the test-class and it nevertheless works, even though you
> don't pass any String, you just push the "execute" button and it all
> magically works..
> Can someone explain that, please?
JUnit uses reflection to collect all public methods that start with
"test" and then executes them.

Dani
>
> Best regards
Previous Topic:options java appearance "show categories"
Next Topic:Problem with Eclipse Helios
Goto Forum:
  


Current Time: Fri Apr 26 19:25:03 GMT 2024

Powered by FUDForum. Page generated in 0.03365 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top