Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.NoClassDefFoundError: org/dbunit/dataset/ITableMetaData when run test with@ExpectedDatabase #151

Open
dory2100 opened this issue Sep 8, 2020 · 3 comments

Comments

@dory2100
Copy link

dory2100 commented Sep 8, 2020

My Project: Spring boot 2.3.3+testng7.1.0+spring-test-dbunit-core5.2.0

run test method as below and get NoClassDefFoundError,need further help.

@DatabaseSetup("OtpSendcode.xml")
@DatabaseTearDown("OtpSendcode.xml")
@ExpectedDatabase("expectedData.xml")
@Test(description = "token miss scenario",retryAnalyzer = RetryConfig.class)
public void test1() {
    body.put("mobileNo", "13929552529");
    body.put("_signature", "7066c781bd0e8ebc679e07e4a4f9edbbf024d6e7aa94b36644c6addd7704cd56");
    body.put("_keys", "_nonceStr,bizCode,mobileNo");
    body.put("bizCode", "otp_login");
    body.put("_nonceStr", "Bk5eY9RAFA8GLs0iUJJSuSNKUpkb7fbf");
    try {
        String res = baseTest.doPostWithJson(body);
        logger.info("res===" + res);
        Assert.assertEquals(res, "{\"code\":\"9999\",\"message\":\"Token miss \"}");
    } catch (Exception e) {
        e.printStackTrace();
    }
}
@ppodgorsek
Copy link
Owner

Could you provide the name of the class that cannot be found please?

@dory2100
Copy link
Author

The class that cannot be found is org/dbunit/dataset/ITableMetaData.I've had this issue resolved by adding dbunit dependency to pom.

@dory2100
Copy link
Author

But I have another issue with annotation @DatabaseSetup("OtpSendcode.xml") when I run test case.The dataset xml file is in the same directory as test case.

java.lang.IllegalArgumentException: Unable to load dataset from "com/dory/pais/cases/app/OtpSendcode.xml" using class com.github.springtestdbunit.dataset.FlatXmlDataSetLoader

at org.springframework.util.Assert.notNull(Assert.java:201)
at com.github.springtestdbunit.DbUnitRunner.loadDataset(DbUnitRunner.java:247)
at com.github.springtestdbunit.DbUnitRunner.loadDataSets(DbUnitRunner.java:212)
at com.github.springtestdbunit.DbUnitRunner.setupOrTeardown(DbUnitRunner.java:189)
at com.github.springtestdbunit.DbUnitRunner.beforeTestMethod(DbUnitRunner.java:79)
at com.github.springtestdbunit.DbUnitTestExecutionListener.beforeTestMethod(DbUnitTestExecutionListener.java:180)
at org.springframework.test.context.TestContextManager.beforeTestMethod(TestContextManager.java:289)
at org.springframework.test.context.testng.AbstractTestNGSpringContextTests.springTestContextBeforeTestMethod(AbstractTestNGSpringContextTests.java:158)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:134)
at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:63)
at org.testng.internal.ConfigInvoker.invokeConfigurationMethod(ConfigInvoker.java:348)
at org.testng.internal.ConfigInvoker.invokeConfigurations(ConfigInvoker.java:302)
at org.testng.internal.TestInvoker.runConfigMethods(TestInvoker.java:695)
at org.testng.internal.TestInvoker.invokeMethod(TestInvoker.java:523)
at org.testng.internal.TestInvoker.invokeTestMethod(TestInvoker.java:173)
at org.testng.internal.MethodRunner.runInSequence(MethodRunner.java:46)
at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:816)
at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:146)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128)
at java.util.ArrayList.forEach(ArrayList.java:1257)
at org.testng.TestRunner.privateRun(TestRunner.java:766)
at org.testng.TestRunner.run(TestRunner.java:587)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:384)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:378)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:337)
at org.testng.SuiteRunner.run(SuiteRunner.java:286)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1187)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1109)
at org.testng.TestNG.runSuites(TestNG.java:1039)
at org.testng.TestNG.run(TestNG.java:1007)
at com.intellij.rt.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:66)
at com.intellij.rt.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:109)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants