TestNG does not run tests in the test suite

I try to run a test suite using XML and TestNG, but I always get 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 reads correctly, but it seems that the tests are not running.

This is 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 in Eclipse looks like:

TestNG Directory Structure in Eclipse

In addition, I am also trying to run a test 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 tried cleaning up the project via eclipse and that didn't seem to help. I also tried to run:

mvn cleanbut that didn't help either.

Any help sent to me in the right direction would be greatly appreciated!

+8
source share
13 answers

, :

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

, :

import org.junit.Test;
+16

, .

+7

-, TestNG XML .

, . testng.xml , :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="TestingSuite" parallel="none">
  <test name="Test1">
    <classes>
      <class name="tests.Page1"/>
    </classes>
  </test>
    <test name="Test 2">
        <classes>
            <class name="tests.Page2"/>
        </classes>
    </test>
</suite>
+4

, Eclipse (Project- > Clean- > Clean Selected)

+2

@Test IDE import org.junit.Test.

import org.testng.annotations.Test .

+1

"enabled = false" @Test (...). , "true".

0

, . Eclipse. , , , , .

0

, :

src/test/java/com/temporary/core

src/test/resources/com/temporary/Core

, testng .

Core tcore, .

0

, :

  1. TestNG lib

    . com.beust.jcommander_1.72.0.jar

    . org.apache-extras.beanshell.bsh_2.0.0.b6.jar

    . org.testng_6.14.2.r201802161450.jar

    . or.yaml.snakeyaml_1.17.0.jar

  2. - chromedriver lib,

  3. ( testng.xml ) :

    java -cp.\lib\*;.\target\classes org.testng.TestNG testng.xml

0

, / TestNG ,

0

, . @Test @Test, @Test .

0

I ran into the same problem - the file was read correctly, but the tests did not run. I can run a test case on my machine, but I am facing the same problem in a virtual machine. I would be grateful for any contribution. Thank you

0
source

if the @Test method is public boolean () with the return type true / flase, it fails .. strange, but worked in my case.

0
source

Source: https://habr.com/ru/post/1532152/


All Articles