我正在尝试使用Codepro Analytix v7.1
中的RAD 7.5
生成JUnit测试用例
即使是简单的源代码,我也会获得ClassNotFoundException
。
源代码:
package com.tmp;
public class General {
public int getPriceRate(){
Calculation calc = new CalculationImpl();
return calc.getPrice(20);
}
}
生成的测试代码:
package com.tmp;
import org.junit.*;
import static org.junit.Assert.*;
/**
* The class <code>GeneralTest</code> contains tests for the class <code>{@link General}</code>.
*
* @generatedBy CodePro at 3/8/12 5:10 AM
*/
public class GeneralTest {
/**
* Run the int getPriceRate() method test.
*
* @throws Exception
*
* @generatedBy CodePro at 3/8/12 5:10 AM
*/
@Test
public void testGetPriceRate_1()
throws Exception {
General fixture = new General();
int result = fixture.getPriceRate();
// add additional test code here
// An unexpected exception was thrown in user code while executing this test:
// java.lang.ClassNotFoundException: com.tmp.General
// at java.net.URLClassLoader.findClass(Unknown Source)
// at java.lang.ClassLoader.loadClass(Unknown Source)
// at com.instantiations.assist.eclipse.junit.execution.core.UserDefinedClassLoader.loadClass(Unknown Source)
// at java.lang.ClassLoader.loadClass(Unknown Source)
// at com.instantiations.assist.eclipse.junit.execution.core.ExecutionContextImpl.getClass(Unknown Source)
// at com.instantiations.eclipse.analysis.expression.model.SimpleTypeExpression.execute(Unknown Source)
// at com.instantiations.eclipse.analysis.expression.model.MethodInvocationExpression.execute(Unknown Source)
// at com.instantiations.assist.eclipse.junit.execution.core.ExecutionRequest.execute(Unknown Source)
// at com.instantiations.assist.eclipse.junit.execution.communication.LocalExecutionClient$1.run(Unknown Source)
// at java.lang.Thread.run(Unknown Source)
assertEquals(0, result);
}
}
你能帮我解决一下这个错误吗?