Running all tests in eclipse workspace?

561 views
Skip to first unread message

Barry Kaplan

unread,
Feb 6, 2006, 2:58:52 PM2/6/06
to testng...@googlegroups.com
I have setup an eclipse project that depends on all other projects. Those projects export all their classes including the tests. I then setup a simple testng.xml as such:

[code]
<suite name="fn-unit-tests" verbose="1">
<test name="Unit Test">
<groups>
<run>
<include name="unit" />
<include name="unit.spring" />
</run>
</groups>
</test>
</suite>
[/code]

(Why does not format correctly?)

But no tests are found nor run. I have even imported the class folder directly. Still no tests.

I really need a project that runs all the unit tests for all projects. Sure I can go to ant, but right now I don't even have an ant build setup. Besides, I want to run this in the plugin runner.

Am I missing something simple, or does the plugin explicity only run tests from the current projects output folder(s)?
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=17229&messageID=33806#33806

Cédric Beust ♔

unread,
Feb 6, 2006, 3:20:30 PM2/6/06
to testng...@googlegroups.com
Maybe the plug-in doesn't take projects you depend on into account...

Alexandru?

--
Cedric
--
Cédric

Barry Kaplan

unread,
Feb 6, 2006, 3:32:06 PM2/6/06
to testng...@googlegroups.com
On a releated note, can I specify a wildcard in the <classes> element? I want to say

"run group 'unit' for all classes in the project"

But 'class name="*"' doesn't work. I can't find any example in the docs that do anything like this.


---------------------------------------------------------------------
Posted via Jive Forums

http://forums.opensymphony.com/thread.jspa?threadID=17229&messageID=33817#33817

Cédric Beust ♔

unread,
Feb 6, 2006, 3:37:15 PM2/6/06
to testng...@googlegroups.com
On 2/6/06, Barry Kaplan <testng...@opensymphony.com> wrote:

On a releated note, can I specify a wildcard in the <classes> element? I want to say

"run group 'unit' for all classes in the project"

But 'class name="*"' doesn't work. I can't find any example in the docs that do anything like this.

It's not implemented yet (but on my list).   In the meantime, you can use wildcards with <package> or on class names in build.xml...

--
Cédric

Barry Kaplan

unread,
Feb 6, 2006, 3:44:32 PM2/6/06
to testng...@googlegroups.com
I got this to work. It seems that it cannot be done using the testng.xml, but it can by creating a dynamic suite using the plugin. But its somewhat klugy:

- create project A, project B
- add tests to A and B with the group name "unit"
- create project Test and have it depend on A and B
- create a new run configuration, set the project to Test

Now at this point I want to specify the "unit" group but cannot because the only way to specify a group is to select one. Since Test does not define any tests itself, there are not groups to select. So....

- change run configuration to either project A or B
- now select the "unit" group
- change the run configuration back to project Test

Now all tests in the dependent projects with the group "unit" will run.

(I'll submt a jira issue that references this thread)


---------------------------------------------------------------------
Posted via Jive Forums

http://forums.opensymphony.com/thread.jspa?threadID=17229&messageID=33820#33820

Barry Kaplan

unread,
Feb 6, 2006, 3:46:13 PM2/6/06
to testng...@googlegroups.com
http://jira.opensymphony.com/browse/TESTNG-28

(No up-to-date versions in jira for testng?)


---------------------------------------------------------------------
Posted via Jive Forums

http://forums.opensymphony.com/thread.jspa?threadID=17229&messageID=33821#33821

Barry Kaplan

unread,
Feb 6, 2006, 3:57:43 PM2/6/06
to testng...@googlegroups.com
"build.xml" meaning with ant? I am working stricly in the IDE. We use ant only for the very final build and deployment. I'm mainly looking for usability in day-to-day development.

(But see my reply above, I have found a workaround)


---------------------------------------------------------------------
Posted via Jive Forums

http://forums.opensymphony.com/thread.jspa?threadID=17229&messageID=33828#33828

Cédric Beust ♔

unread,
Feb 6, 2006, 4:08:26 PM2/6/06
to testng...@googlegroups.com
On 2/6/06, Barry Kaplan <testng...@opensymphony.com> wrote:

http://jira.opensymphony.com/browse/TESTNG-28

(No up-to-date versions in jira for testng?)

I just added version 4.5 to JIRA.

--
Cédric

Alexandru Popescu

unread,
Feb 6, 2006, 6:03:32 PM2/6/06
to testng...@googlegroups.com
#: Barry Kaplan changed the world a bit at a time by saying (astral date: 2/6/2006 9:58 PM) :#

Hi Barry!

Can you please check what is the command line used to launch TestNG in this scenario? You can find
this line in the .log file of your workspace.

I suspect that the following is happening: you are using JDK1.4, and for this TestNG needs access to
the source dirs. While using project dependencies, the plugin is not reaching the other projects
source dirs, and as a result it is not able to run tests in those projects.

In case you are using JDK1.5, I don't have any ideas (yet).

./alex
--
.w( the_mindstorm )p.

Barry Kaplan

unread,
Feb 6, 2006, 8:00:53 PM2/6/06
to testng...@googlegroups.com
I am using 1.5 as the jdk and 1.5 for selected for the run target. Here is the command:

----
!ENTRY org.testng.eclipse 1 1 2006-02-06 19:55:09.703
!MESSAGE [-port, 3678, -sourcedir, Q:\folio\portfolio\src\prod\java;Q:\folio\portfolio\src\prod\conf;Q:\folio\portfolio\src\test\conf;Q:\folio\portfolio\src\test\java;Q:\folio\platform\src\prod\java;Q:\folio\platform\src\test\conf;Q:\folio\platform\src\prod\conf;Q:\folio\platform\src\test\java, -d, Q:\folio\test, Q:\folio\test\testng.xml]
----

For the dependent projects the /source/ directories are in the path, not the output folders.

But.... Here is the command for the target that does work. This target was created as I described above (ie, by tricking the plugin to use the groups):

----
!ENTRY org.testng.eclipse 1 1 2006-02-06 19:58:07.875
!MESSAGE [-port, 3695, -sourcedir, Q:\folio\portfolio\src\prod\java;Q:\folio\portfolio\src\prod\conf;Q:\folio\portfolio\src\test\conf;Q:\folio\portfolio\src\test\java;Q:\folio\platform\src\prod\java;Q:\folio\platform\src\test\conf;Q:\folio\platform\src\prod\conf;Q:\folio\platform\src\test\java, -d, Q:\folio\portfolio, Q:\folio\portfolio\fn-portfolio_Custom_suite_c9d431a9.xml]
----

The are the same! The only difference is that the generated suite has the <classes> entries that it auto-discovered. So does this mean that the classes must always be specified even if a group is selected?


---------------------------------------------------------------------
Posted via Jive Forums

http://forums.opensymphony.com/thread.jspa?threadID=17229&messageID=33881#33881

Alexandru Popescu

unread,
Feb 6, 2006, 8:44:27 PM2/6/06
to testng...@googlegroups.com
#: Barry Kaplan changed the world a bit at a time by saying (astral date: 2/7/2006 3:00 AM) :#

Ugly :-). Can you please paste the 2 suites (the one you created vs the one autogenerated - by the
way, I never thought the autogeneration would work better than the manual one :-) ).

I guess that indeed the classes or packages must be provided in the suite. The reason is that
without it TestNG would have to load all classes in the classpath and investigate each of them to
see if they are part of the group. This would take an eternity with real projects. So, in order to
keep things at a normal speed you will have to provide at least the packages where TestNG should look.

Does this makes sense?

cheers,

Barry Kaplan

unread,
Feb 7, 2006, 9:36:51 AM2/7/06
to testng...@googlegroups.com
With junit we have a TestCollectingSuite which will scan all classes in a partial class path. Of course, this is junit3 and its easy to check for the TestCase superclass. Hmm, actually it would be just as easy to check for annation and then the group. We never found this apporach to be slow, even with 10k tests. (Of course we configured the collector to only scan classes in a test output folder, so most of the classes were indeed tests.)

Manually created suite:
---


<suite name="fn-unit-tests" verbose="1">
<test name="Unit Test">
<groups>
<run>
<include name="unit" />
<include name="unit.spring" />
</run>
</groups>
</test>
</suite>

---

Plugin generated suite:
----
<suite name="Custom suite">
<test verbose="2" name="fn-test" annotations="1.5">
<groups>
<run>
<include name="unit, unit.spring"/>
<include name="unit"/>
</run>
</groups>
<classes>
<class name="org.opentrader.infra.hibernate.DAOPersistentClassBeanFactoryPostProcessorTest"/>
<class name="org.opentrader.infra.lingo.MaskedTopicFactoryTest"/>
<class name="org.opentrader.infra.lingo.SingleArgumentTopicResolverTest"/>
</classes>
</test>
</suite>
----


---------------------------------------------------------------------
Posted via Jive Forums

http://forums.opensymphony.com/thread.jspa?threadID=17229&messageID=34037#34037

Alexandru Popescu

unread,
Feb 7, 2006, 1:37:05 PM2/7/06
to testng...@googlegroups.com
#: Barry Kaplan changed the world a bit at a time by saying (astral date: 2/7/2006 4:36 PM) :#

Barry I tend to disagree with you. Looking at each class if it extends some TestClass is quite easy.
Moreover I think that in JUnit you are specifying where you should look for those. Now compair
this with scanning all the classes in the classpath, reading all methods and check for an
annotation. Doesn't look quite the same. Moreover, I don't see a good reason why you shouldn't
provide a org.opentrader.infra.* package.

Barry Kaplan

unread,
Feb 7, 2006, 6:53:17 PM2/7/06
to testng...@googlegroups.com
Actually we agree. I see no problem specifying the package.

When we scanned the classpath it was /not/ the entire classpath, but just the specific folders which we knew to contain our tests. (This was in Idea, pre-module days. So all tests were in a single directory.) We never scanned jars and such.

Even now, I don't want to scan jars. I just want to pick up all our tests from all our eclipse projects. If a "org.opentrader.*" will do the trick, I'm more than happy.

-barry


---------------------------------------------------------------------
Posted via Jive Forums

http://forums.opensymphony.com/thread.jspa?threadID=17229&messageID=34164#34164

Alexandru Popescu

unread,
Feb 7, 2006, 8:44:18 PM2/7/06
to testng...@googlegroups.com
#: Barry Kaplan changed the world a bit at a time by saying (astral date: 2/8/2006 1:53 AM) :#

I expect it to work with a package. Please keep us updated.

cheers,

Barry Kaplan

unread,
Feb 8, 2006, 8:34:17 AM2/8/06
to testng...@googlegroups.com
(I aspect in another thread where the <packages> was documented. Sorry, I found it.)

And it does indeed work!

So one only has to create an eclipse project that depends on all other projects. Create a testng.xml similar to below, and all tests selected from all projects will run. Thanks!!

<suite name="fn-unit-tests" verbose="1">
<test name="Unit Test">
<groups>
<run>
<include name="unit" />
<include name="unit.spring" />
</run>
</groups>

<packages>
<package name="org.opentrader.*" />
</packages>
</test>
</suite>

-barry
---------------------------------------------------------------------
Posted via Jive Forums

http://forums.opensymphony.com/thread.jspa?threadID=17229&messageID=34318#34318

Alexandru Popescu

unread,
Feb 8, 2006, 9:55:10 AM2/8/06
to testng...@googlegroups.com
#: Barry Kaplan changed the world a bit at a time by saying (astral date: 2/8/2006 3:34 PM) :#

Thanks for the confirmation Barry!

Reply all
Reply to author
Forward
0 new messages