I'm new to TestNG and I'm trying to figure out if I'm doing something
wrong. I've created a simple testng.xml and Eclipse launcher to try
to run all of my unit tests. It is currently covering a source folder
with mostly JUnit tests that I plan to convert if all goes well.
I'm trying to run a suite that will automatically find everything it
needs without developers having to remember to updating the XML file
constantly.
Here's my suite:
<suite name="All" verbose="10">
<test name="Regression">
<packages>
<package name="com.workscape.*"/>
</packages>
</test>
</suite>
When running under the test runner in Eclipse, there seems to be some
sort of classpath issue for how TestNGClassFinder determines which
classes are tests. Here's the output. It should be finding six
tests.
The run configuration for the Eclipse launcher has the correct
classpath that definitely includes the proper Hibernate jars. If I
change the suite to include only that package that actually has TestNG
tests (com.workscape.inputfile.*), everything behaves.
Do you have any suggestions?
Regards,
Tim
[Parser] Running:
C:\views\td_caps_7.3\apps_compplanner\platform\sdk\src\java\test
\testng.xml
[RunInfo] Adding method selector:
org.testng.internal.XmlMethodSelector@119298d priority: 10
[TestNGClassFinder] SKIPPING CLASS class
com.workscape.directory.v1.ServiceManagement$13 no TestNG annotations
found
[TestNGClassFinder] SKIPPING CLASS class
com.workscape.poi.TestWorksheetSchema no TestNG annotations
foundTestNG annotations found
....
....
[TestNGClassFinder] SKIPPING CLASS class
com.workscape.oneforce.auth.ProxyLifeCycleServiceImpl no TestNG
annotations found
===============================================
All
Total tests run: 0, Failures: 0, Skips: 0
===============================================
java.lang.NoClassDefFoundError: net/sf/hibernate/Session
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
at java.lang.Class.privateGetPublicMethods(Class.java:2547)
at java.lang.Class.getMethods(Class.java:1410)
at
org.testng.internal.TestNGClassFinder.isTestNGClass(TestNGClassFinder.java:
157)
at
org.testng.internal.TestNGClassFinder.<init>(TestNGClassFinder.java:
57)
at org.testng.TestRunner.initMethods(TestRunner.java:252)
at org.testng.TestRunner.init(TestRunner.java:198)
at org.testng.TestRunner.init(TestRunner.java:168)
at org.testng.TestRunner.<init>(TestRunner.java:135)
at org.testng.remote.RemoteTestNG$1.newTestRunner(RemoteTestNG.java:
102)
at org.testng.remote.RemoteTestNG
$DelegatingTestRunnerFactory.newTestRunner(RemoteTestNG.java:152)
at org.testng.SuiteRunner
$ProxyTestRunnerFactory.newTestRunner(SuiteRunner.java:457)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:212)
at org.testng.SuiteRunner.run(SuiteRunner.java:168)
at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:987)
at org.testng.TestNG.runSuitesLocally(TestNG.java:951)
at org.testng.TestNG.run(TestNG.java:719)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:73)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:122)
Well, I don't think it is a TestNG problem. What you are seeing is a
runtime dependency that is not expressed in your current project
classpath (hibernate). If you will make sure it is part of the
classpath (with its all required dependencies) I am quite sure TestNG
will be able to load the classes.
However, you are saying that your source code contains "mostly JUnit
tests". You will need to tell TestNG which tests classes are JUnit so
that it will run them in JUnit mode (and remember that this will work
only with JUnit 3.x tests). Please check the documentation about the
suite definition file on how to specify that the tests are JUnit
(basically it is as simple as adding the attribute junit="true" on one
of the <test> or <suite> elements).
bests,
./alex
--
.w( the_mindstorm )p.
TestNG co-founder
EclipseTestNG Creator
The odd thing is that if I specify the package where the TestNG tests
are directly in the suite, everything works fine. It seems like the
problem is more related to the finder trying to find tests in other
packages.
Regards,
Tim
On May 15, 11:22 am, "Alexandru Popescu ☀"
<the.mindstorm.mailingl...@gmail.com> wrote:
I think I am writting this information in the .log file, so please try
to check it there (the classpath + the parameters used to trigger
TestNG).