zoukankan      html  css  js  c++  java
  • Junit 命令行测试 报错:Could not find class 理解及解决方法

    一、报错 : 『Could not find class』

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

    1. 
    MyComputer:bin marikobayashi$ java -cp  .:./junit-4.10.jar org.junit.runner.JUnitCore NextdayTest 
    JUnit version 4.10
    ...............
    Time: 0.016
    
    OK (15 tests)
    
    2.
    MyComputer:bin marikobayashi$ java -cp  .:./junit-4.10.jar org.junit.runner.JUnitCore ./NextdayTest 
    JUnit version 4.10
    Could not find class: ./NextdayTest
    
    Time: 0.002
    
    OK (0 tests)
    
    
    3.
    MyComputer:bin marikobayashi$ java -cp ./junit-4.10.jar org.junit.runner.JUnitCore ./NextdayTest 
    JUnit version 4.10
    Could not find class: ./NextdayTest
    
    Time: 0.001
    
    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 : 前面不要加 路径,否则可能找不到(会被一并认为测试脚本类名)
  • 相关阅读:
    在Windows Phone应用中使用Google Map替代Bing Map
    《从入门到精通:Windows Phone 7应用开发》
    判断最小割的唯一性
    ASP.NET页面生命周期
    SQL排序
    window.open
    VS2008中英文转换
    asp.net下载文件的常用方法
    TSQL Convert转换时间类型
    TreeView
  • 原文地址:https://www.cnblogs.com/juking/p/6854950.html
Copyright © 2011-2022 走看看