我做错了什么???我不知道为什么参数不通过! 我试图从外部Excel工作表中传递值...请帮助!!
请大家不要将此标记为重复!! 提前致谢
P.S我试图不使用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)
答案 0 :(得分:0)
不确定为什么需要使用第三方库来运行带有DataDrivenTestRunner.class的TestNG。以下适用于所有情况,没有任何问题。另外,为什么你创建TestNGTestCases类既不是扩展它也不是为它添加任何测试。
function disableTimeout(_this){
$(_this).prop('disabled','disabled');
setTimeout(function(){
$(_this).prop('disabled','');
}, 5000); // 5sec
}
$("#Save").click(function () {
alert('saved!');
disableTimeout(this);
});