JUnit 4

Doesn't TeamCity support JUnit 4? I just added a test case that doesn't
extend TestCase and TeamCity tells me there are no tests found in my class.

Thanks,
Robert

11 comments
Comment actions Permalink

Robert Gibson wrote:

Doesn't TeamCity support JUnit 4? I just added a test case that doesn't
extend TestCase and TeamCity tells me there are no tests found in my class.


TeamCity's build agent uses junit-3.8.1 (it's jar is located at
buildAgent/plugins/ant/lib directory). You can try to replace it with junit-4.jar,
I think this should solve the problem.

Hope this helps,
KIR


--
Kirill Maximov
Software Developer
JetBrains, Inc.
http://www.jetbrains.com
"Develop with pleasure!"

0
Comment actions Permalink

Do you mean put junit-4.1.jar in the same directory or remove
junit-3.8.1.jar and put junit-4.1.jar or rename junit-4.1.jar as
junit-3.8.1.jar or ... ?
R

0
Comment actions Permalink

Robert Gibson wrote:

Do you mean put junit-4.1.jar in the same directory or remove
junit-3.8.1.jar and put junit-4.1.jar or rename junit-4.1.jar as
junit-3.8.1.jar or ... ?


I mean remove junit-3.8.1.jar and add junit-4.1.jar. No need to rename.

R



--
Kirill Maximov
Software Developer
JetBrains, Inc.
http://www.jetbrains.com
"Develop with pleasure!"

0
Comment actions Permalink

Unfortunately it doesn't work because it seems the old test runner is
being used which doesn't understand pure 4.1 tests. I keep getting "No
tests found". I've filed a bug: http://www.jetbrains.net/jira/browse/TW-1007

Thanks,
R

0
Comment actions Permalink

Robert Gibson wrote:

Unfortunately it doesn't work because it seems the old test runner is
being used which doesn't understand pure 4.1 tests. I keep getting "No
tests found". I've filed a bug:
http://www.jetbrains.net/jira/browse/TW-1007


How do you run your tests from Ant? In fact, default junit task in ant cannot
find JUnit4 tests.

It looks like Ant's JUnit runner cannot recognize JUnit4 tests.

KIR


--
Kirill Maximov
Software Developer
JetBrains, Inc.
http://www.jetbrains.com
"Develop with pleasure!"

0
Comment actions Permalink

I'm using Idea to run my tests locally and the lpr runner (not ant) on
the server. I suppose it doesn't work because you do a .lpr->ant file
conversion behind the scenes.
R

0
Comment actions Permalink

Robert Gibson wrote:

I'm using Idea to run my tests locally and the lpr runner (not ant) on
the server. I suppose it doesn't work because you do a .lpr->ant file
conversion behind the scenes.


Well, you're right here. There is such conversion.
Looks like we have to write a JUnit4 ant runner :-o

We'll consider whan can be done here. Thanks for the report.

Kind regards,
KIR


--
Kirill Maximov
Software Developer
JetBrains, Inc.
http://www.jetbrains.com
"Develop with pleasure!"

0
Comment actions Permalink

Kirill Maximov (JetBrains) wrote:


Well, you're right here. There is such conversion.

That's pretty obvious from the ugly output :-/
http://www.jetbrains.net/jira/browse/TW-1019

Looks like we have to write a JUnit4 ant runner :-o

The 1.7 beta Ant ]]> task available from CVS can handle both JUnit
3.8.x and JUnit 4.0 tests.
R

0
Comment actions Permalink

Is there a temporary workaround for this? All our tests are JUnit4, and this limitation really prevents us from using TeamCity effectively.

0
Comment actions Permalink

Jon Nichols wrote:

Is there a temporary workaround for this? All our tests are JUnit4, and this limitation really prevents us from using TeamCity effectively.


Yes, there is a workaround. Check out
http://www.jetbrains.net/jira/browse/TW-1007

--
Alexey Gopachenko
JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0
Comment actions Permalink

If you don't want to mess about with the bundled ant, you can switch to ant 1.7 on a per build configuration basis - just install ant 1.7 to some other directory and then set the Ant Home field on the build config to point to this install.

We do this and can run both Junit 3 & 4 unit tests.

This also means you don't have to keep changing the bundled ant everytime a new version of TC is released.

0

Please sign in to leave a comment.