我正在为我的论文开发一个网络应用程序。现在我就是那个部分,我想在那个网络应用程序上运行自动化测试。问题是,我无法运行此测试。 Stacjtrace说他找不到我想要测试的班级的课程。
我已经调试并查看了NetBeans中加载了哪些类。似乎只有我测试的类被加载了。有人告诉我,我必须运行一个嵌入式GlassFish。
提前致谢
Testcase: testGetInstance(org.iav.io.IOFacadeTest): Caused an ERROR
null
java.lang.ExceptionInInitializerError
at org.iav.io.IOFacade.<init>(IOFacade.java:32)
at org.iav.io.IOFacade.getInstance(IOFacade.java:47)
at org.iav.io.IOFacadeTest.testGetInstance(IOFacadeTest.java:50)
Caused by: java.lang.NullPointerException
at org.iav.io.LicenseListFileBean.<clinit>(LicenseListFileBean.java:47)
Testcase: testGetPoolSize(org.iav.io.IOFacadeTest): Caused an ERROR
Could not initialize class org.iav.io.LicenseListFileBean
java.lang.NoClassDefFoundError: Could not initialize class org.iav.io.LicenseListFileBean
at org.iav.io.IOFacade.<init>(IOFacade.java:32)
at org.iav.io.IOFacadeTest.testGetPoolSize(IOFacadeTest.java:63)
类IOFacade:
@ApplicationScoped
public class IOFacade extends Observable {
private static IOFacade instance;
private UserListFileBean userListFileBean;
private LicenseListFileBean licenseListFileBean;
private FileAccessorBean fileAccessorBean;
/**
* Constructor for this class. Initializing also dependent classes.
* Encapsulates IO-Subsystem from beeing direct accessed.
*/
public IOFacade() {
licenseListFileBean = LicenseListFileBean.getInstance();
userListFileBean = UserListFileBean.getInstance();
fileAccessorBean = FileAccessorBean.getInstance();
/** Registering this instance at fileAccessorBean to be notified if list
* has changed.
*/
addObserver(fileAccessorBean);
}
答案 0 :(得分:0)
是的,单元测试只涉及您正在测试的课程。您必须模拟单元测试的容器类。
如果你所追求的是集成或系统测试,它测试你的类如何与它的环境交互,那么你需要在嵌入式环境中运行你的应用程序。查看Arquillian,它提供了一种简单易用的方式来管理您的嵌入式测试环境。适用于Glassfish 3.0.1,JBoss和其他一些容器。