Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TestNG not running tests in testing suite

I'm trying to run a testing suite using XML and TestNG, but I'm always getting the same message using both: Eclipse and the command line:

[TestNG] Running:
  /Users/achavez/Programs/Selenium/java/src/tests/resources/testng.xml


===============================================
TestingSuite1
Total tests run: 0, Failures: 0, Skips: 0
===============================================

The file is read correctly, but it seems like the tests are not running.

These are the contents of my testng.xml:

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="TestingSuite1" verbose="1">
    <test name="Test1"  >
        <packages>
            <package name="tests"/>
        </packages>
    </test>
</suite>

and this is how my directory structure looks like in Eclipse:

TestNG Directory Structure in Eclipse

Also, this is also how I'm attempting to run the testing suite through the command line:

java -jar /Applications/Zend\ Studio.app/Contents/Resources/Java/plugins/org.testng.eclipse_6.8.6.20141201_2240/lib/testng.jar src/tests/resources/testng.xml

I've tried cleaning the project through eclipse, and that didn't seem to help. I also tried running:

mvn clean but it didn't do the job either.

Any help pointing me to the right direction will be greatly appreciated!

like image 767
ILikeTacos Avatar asked Mar 17 '14 14:03

ILikeTacos


People also ask

How do you resolve TestNG no tests found nothing was run?

Solution. The easiest solution would be to change the @BeforeTest annotation with @Test and execute you Test case / Test Suite.

Why TestNG is not showing in run as?

After you have installed TestNG eclipse plugin, you need to create a TestNG run configuration. From the menu bar select: Run > Run Configurations. Select 'TestNG' from the list and select 'New Lanuch Configuration'. In there select class, method, whatever you want to run.

Why tests are ignored in TestNG?

There are various reasons why TestNG is skipping the tests, the most common one is that a method you depend on (e.g. testOpen or createCorrect) failed in some way. I suggest setting the verbose level to 10 and paste the output here or on the testng-users mailing-list.


2 Answers

You could also check imports for imported Test annotation, should be:

import org.testng.annotations.Test;
@Test
public myTest(){ ... }

and not for example:

import org.junit.Test;
like image 51
teejay Avatar answered Oct 25 '22 00:10

teejay


I had to change my method access modifier to public from private to get it working .

like image 33
Sindhu Avatar answered Oct 25 '22 01:10

Sindhu