I configured my eclipse environment to generate a TESTNG.xml file.
My code has this:
package testMy;
public class testMy {
public static void main(String[] args) {
System.out.println("Hello!");
}
}
I installed TESTNG plugin and then i click on the project and selected option "convert to TESTNG"
I got this XML:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
<suite name="Suite">
<test thread-count="5" name="Test">
</test> <!-- Test -->
</suite> <!-- Suite -->
Is it valid? I do not see any "Hello!" message or something like that inside of that?
Am i missing anything?
Add this under test
<classes>
<class name="myTest.DemoTest"/>
</classes>
├── pom.xml
└── src
├── main
│ ├── java
│ │ └── testMy
│ │ └── testMy.java
│ └── resources
└── test
├── java
│ └── testMy
│ └── DemoTest.java
└── resources
└── testng.xml
package testMy;
public class testMy {
public static void main(String[] args) {
System.out.println("Hello!");
}
public String echo(String msg) {
return msg;
}
public String hello(String msg) {
return "Hello "+msg;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<suite name="Suite" parallel="false">
<test name="Test">
<classes>
<class name="myTest.DemoTest"/>
</classes>
</test> <!-- Test -->
</suite> <!-- Suite -->
package testMy;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class DemoTest {
private testMy theOne=null;
@BeforeClass
public void setUp() {
theOne =new testMy();
}
@Test
public void testEcho() {
Assert.assertEquals("AAAA",theOne.echo("AAAA"));
}
@Test
public void testHello() {
Assert.assertEquals("Hello AAAA",theOne.hello("AAAA"));
}
}