一、报错 : 『Could not find class』

下面给出三个示例比较,其中只有第一个是正确的。

  1. 1.
  2. MyComputer:bin marikobayashi$ java -cp .:./junit-4.10.jar org.junit.runner.JUnitCore NextdayTest
  3. JUnit version 4.10
  4. ...............
  5. Time: 0.016
  6. OK (15 tests)
  7. 2.
  8. MyComputer:bin marikobayashi$ java -cp .:./junit-4.10.jar org.junit.runner.JUnitCore ./NextdayTest
  9. JUnit version 4.10
  10. Could not find class: ./NextdayTest
  11. Time: 0.002
  12. OK (0 tests)
  13. 3.
  14. MyComputer:bin marikobayashi$ java -cp ./junit-4.10.jar org.junit.runner.JUnitCore ./NextdayTest
  15. JUnit version 4.10
  16. Could not find class: ./NextdayTest
  17. Time: 0.001
  18. OK (0 tests)

二、 分析

java -cp .:./junit-4.10.jar org.junit.runner.JUnitCore NextdayTest

  1. -cp 指类路径 : "." 指的是当前路径,一定要有; 『:』 是分隔符, 『./junit-4.10.jar』 指当前路径下的./junit-4.10.jar包,也可以在其他路径下
  2. org.junit.runner.JUnitCore : 测试框架入口
  3. NextdayTest :待测Junit 测试用例+脚本 类。 PS : 前面不要加 路径,否则可能找不到(会被一并认为测试脚本类名)

Junit 命令行测试 报错:Could not find class 理解及解决方法的更多相关文章

  1. rpm方式安装MySQL后在命令行登录报错:ERROR 1045 (28000): Unknown error 1045

    1.通过https://mirrors.tuna.tsinghua.edu.cn镜像源安装了MySQL5.7.22 rpm -ivh --force --nodeps https://mirrors. ...

  2. 解压tar.gz文件报错gzip: stdin: not in gzip format解决方法

    解压tar.gz文件报错gzip: stdin: not in gzip format解决方法 在解压tar.gz文件的时候报错 1 2 3 4 5 [Sun@localhost Downloads] ...

  3. 含有package关键字的java文件在命令行运行报错

    程序中含有package关键字,使用命令行运行程序时出现"找不到或无法加载主类",而使用Eclipse软件可以正常运行程序的可能解决办法. 在包下的类,在Java源文件的地方编译后 ...

  4. docker mac 命令行登录报错处理 : Error saving credentials: error storing credentials - err: exit status 1

    参考:https://blog.csdn.net/xufwind/article/details/88756557 比较新版本的docker命令行登录会出现以下错误: Error saving cre ...

  5. 安装 R 包报错 clang: error: unsupported option '-fopenmp' 的解决方法

    MacOS 上安装 R 包 install.packages("data.table") 后面提示是否安装需要编译的版本: Do you want to install from ...

  6. 问题:eclipse中线程编程编译报错,undefined reference to 'pthread_create'的解决方法(已解决)

    问题描述: 在Ubuntu系统中,使用eclipse CDT集成开发环境编写pthread程序,编译时,pthread_create不通过,报错信息是: undefined reference to ...

  7. 安装CentOS 6.x报错"Disk sda contains BIOS RAID metadata"解决方法

    今天在安装CentOS 6.2的时候,当进到检测硬盘的时候,总是过不去,报错如下: Disk sda contains BIOS RAID metadata, but is not part of a ...

  8. scp报错:not a regular file,解决方法:加参数 -r

    命令:scp  -P1234  /data/aa   root@192.0.0..0:/data 文件结构:/data/aa/yearmonth=2015-09 报错:not a regular fi ...

  9. MyEclipse 启动报错:'Building workspace' has encountered a problem解决方法

    转载于:http://blog.csdn.net/v123411739/article/details/42645159 每次MyEclipse工作空间报错如下:'Building workspace ...

随机推荐

  1. python 列表 list的基本操作

    一,Python 的列表数据类型包含更多的方法. 这里是所有的列表对象方法: list.append(x) 把一个元素添加到链表的结尾,相当于 a[len(a):] = [x] . list.exte ...

  2. 深入剖析GPU Early Z优化

    最近在公司群里同事发了一个UE4关于Mask材质的优化,比如在场景中有大面积的草和树的时候,可以在很大程度上提高效率.这其中的原理就是利用了GPU的特性Early Z,但是它的做法跟我最开始的理解有些 ...

  3. linux 的那些hung 检测机制

    在dmesg中,看到如下信息: [:: seconds [:: seconds [:af: seconds [:af: seconds [:: seconds [:3b: seconds [:: se ...

  4. maven学习-基本入门用法

    一.下载及安装 1.1 下载maven 3.1.1 先到官网http://maven.apache.org/download.cgi 下载最新版本(目前是3.1.1 ),下载完成后,解压到某个目录(本 ...

  5. Java并发辅助类的使用

    目录 1.概述 2.CountdownLatch 2-1.构造方法 2-2.重要方法 2-3.使用示例 3.CyclicBarrier 3-1.构造方法 3-2.使用示例 4.Semaphore 4- ...

  6. linux中open函数使用

    open函数用来打开一个设备,他返回的是一个整型变量,如果这个值等于-1,说明打开文件出现错误,如果为大于0的值 参考格式 if(fd=open("/dev/ttys0",O_RD ...

  7. python sqlparse 各种 token

    https://blog.csdn.net/qq_39607437/article/details/79620383 import sqlparse def look(statement): prin ...

  8. week06 codelab01 react-router 去官网学习

    官方教程https://github.com/reactjs/react-router-tutorial git clone 到本地 和教程学 第一课 LESSON 2 index.js引入一些pac ...

  9. CDialogEx::OnPaint()的问题,或者为什么在对话框程序的OnPaint中绘图无效的问题

    这是一个基于对话框的程序,对话框上有按钮,还有几个CStatic用来绘图,之前都是好好的,今天改成Unicode版本后,编译正常,运行时CStatic中的图像怎么也不显示,有时候会闪现一次就消失,问题 ...

  10. git command line 提交代码

    echo "# spring-boot-apollo-demo" >> README.md git init git add README.md git commit ...