单元测试提示找不到“Could not find the main class . Progam will exit”

wangqp1 2010-08-04 10:31:18
使用myeclipse开发工具创建个单元测试,源代码如下

import junit.framework.*;
import UseCase.GeneratePrimes;
package junit.framework;

public class test1 extends TestCase {

public test1(String name) {
super(name);
}

public static void main(String args[])
{
junit.swingui.TestRunner.main(new String[] {"TestGeneratePrimes"});
//testPrimes();
}

public void testPrimes()
{
int[] nullArray = GeneratePrimes.generatePrimes(0);
assertEquals(nullArray.length,0);

int[] minArray = GeneratePrimes.generatePrimes(2);
assertEquals(minArray.length,1);
assertEquals(minArray[0],2);

int[] threeArray = GeneratePrimes.generatePrimes(3);
assertEquals(threeArray.length,2);
assertEquals(threeArray[0],2);
assertEquals(threeArray[1],3);

int[] centArray = GeneratePrimes.generatePrimes(100);
assertEquals(centArray.length,25);
assertEquals(centArray[24],97);
}

}

run as -> Junit test显示如下错误:
java.lang.UnsupportedClassVersionError: Bad version number in .class file
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadTestLoaderClass(RemoteTestRunner.java:324)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.createRawTestLoader(RemoteTestRunner.java:314)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.createLoader(RemoteTestRunner.java:309)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.defaultInit(RemoteTestRunner.java:287)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.init(RemoteTestRunner.java:210)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:195)
...全文
321 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
healer_kx 2010-08-04
  • 打赏
  • 举报
回复
jdk版本不对。
jdk没有配置好。
运行按钮选择要启动的程序,你可能选择错了。
madFatso 2010-08-04
  • 打赏
  • 举报
回复
jdk版本问题
wangqp1 2010-08-04
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 yetaodiao 的回复:]
编译器是myeclipse自带的吧
[/Quote]

是的,也引入了junit.jar包了
  • 打赏
  • 举报
回复
编译器是myeclipse自带的吧
wangqp1 2010-08-04
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 madfatso 的回复:]
jdk版本问题
[/Quote]

确实是版本的问题,后来我更改了jdk路径,就ok了。谢谢你们
西门子plc调试软件,功能强大。具体https://www.mhj-tools.com/winplc-analyzer/ 直接看网页。 先安装软件,然后用文件夹中的破解覆盖。本人亲自破解,只此一家。分数高了点。 With WinPLC-Analyzer you can record signals of a S7-PLC (S7-300, S7-400, S7-1200) or S5-PLC (Simatic S5 series). You can record signals like input, output, flags, data, timer and counter. If you want, you can define a Trigger with S7-STL code. Then you can use this trigger to control the recording or to create a user message. When using S7-300, S7-400 you can also record cyclic exact. This means, that a short program will be transfered into the PLC. This ensures that you see every single edge in the recording. Without modifying the PLC progam you can record "scan exact". That means you can define the sampling rate in ms. With the special recording type "Offline recording", you can record the data within the PLC (without the PC connected). The next day you can transfer the results to your WinPLC-Analyzer project. Additional to the normal trend data, you can define "Snapshots". A "Snapshot" is a range of additional data, that will be stored, if a trigger event is raised. WinPLC-Analyzer also stores the data of the "i-stack" in case of a unexpected "PLC-Stop". Then you can examine the reasons for the PLC-Stop even after days. All software driver are included in the licence of WinPLC-Analyzer. You don't have to pay for every single driver separatly. To access a PLC over TCP/IP you don't need any other software or driver. Only if you want to use a SIEMENS Interface, the driver of it must be installed on the PC.

58,453

社区成员

发帖
与我相关
我的任务
社区描述
Java Eclipse
社区管理员
  • Eclipse
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧