我究竟做错了什么???我不知道为什么不传递参数!!!我正在尝试从外部 excel 表中传递值...请帮助!
伙计们请不要将此标记为重复!提前致谢
PS我试图不使用maven ..
import Data.Bean;
import org.easetech.easytest.annotation.DataLoader;
import org.easetech.easytest.annotation.Param;
import org.easetech.easytest.loader.LoaderType;
import org.easetech.easytest.runner.DataDrivenTestRunner;
import org.junit.runner.RunWith;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
/**
*
* @author Effitrac
*/
public class TestNGTestCases {
public TestNGTestCases() {
}
// TODO add test methods here.
// The methods must be annotated with annotation @Test. For example:
//
// @Test
// public void hello() {}
@BeforeClass
public static void setUpClass() throws Exception {
}
@AfterClass
public static void tearDownClass() throws Exception {
}
@BeforeMethod
public void setUpMethod() throws Exception {
}
@AfterMethod
public void tearDownMethod() throws Exception {
}
/**
*
*/
@RunWith(DataDrivenTestRunner.class)
@DataLoader(filePaths = {"d:/data/kishore/testdata.csv"}, loaderType = LoaderType.CSV)
public class TestExcelDataLoader {
Bean b = new Bean();
@Test
public void testwelcome(@Param(name = "name") String name, @Param(name = "custID") Integer custID) {
System.out.print("Executing getExcelTestData :");
// System.out.println("Name : " + name + " ID : " + custID);
b.setName(name);
b.setCustID(custID);
b.doit();
System.out.println("Name : " + b.getName() + " ID : " + b.getCustID() + " Result : " + b.getResult());
// System.out.println("Name : " + name + " ID : " + custID + " Result : " + b.getResult());
}
}
}
这是我收到的输出....
[TestNG] Running:
Command line suite
[VerboseTestNG] RUNNING: Suite: "Command line test" containing "1" Tests (config: null)
[VerboseTestNG] SKIPPED: "Command line test" - TestNGTestCases$TestExcelDataLoader.testwelcome(java.lang.String, java.lang.Integer) finished in 16 ms
[VerboseTestNG] org.testng.TestNGException:
[VerboseTestNG] Method testwelcome requires 2 parameters but 0 were supplied in the @Test annotation.
[VerboseTestNG]
[VerboseTestNG] ===============================================
[VerboseTestNG] Command line test
[VerboseTestNG] Tests run: 1, Failures: 0, Skips: 1
[VerboseTestNG] ===============================================
===============================================
Command line suite
Total tests run: 1, Failures: 1, Skips: 0
===============================================
Java Result: 2
Deleting directory C:\Users\Effitrac\AppData\Local\Temp\TestNGTestCases
test:
BUILD SUCCESSFUL (total time: 6 seconds)