java命令行执行junit,从命令行运行Junit(Mac)

这一定很明显,但是在查看此处和其他地方后我仍然卡住。我想从命令行运行我的Junit测试。我做了一个脚本化的部署过程,我想在部署之前进行验证。从命令行运行Junit(Mac)

我可以运行此: java命令:/路径/的junit-4.8.1.jar org.junit.runner.JUnitCore HappyPath.class

,我此目录中。类文件。

$ ls -lart

total 40

-rw-r--r-- 1 rdejournett staff 144 Sep 22 12:09 package-info.class

-rw-r--r-- 1 rdejournett staff 11001 Sep 22 12:09 HappyPath.class

drwxr-xr-x 5 rdejournett staff 170 Sep 22 12:09 ..

-rw-r--r-- 1 rdejournett staff 660 Sep 22 12:13 AllTests.class

drwxr-xr-x 5 rdejournett staff 170 Sep 22 12:13 .

但输出是:

JUnit version 4.8.1

Could not find class: HappyPath.class

Time: 0

OK (0 tests)

我需要创建一个JAR文件?

HappyPath类看起来像这样。

@Test

public static void happyPath() {

String xml = "";

xml = ReadJson.ReadFile("/app/mirth/UnitTests/GEoutput.xml");

Statements s = new Statements();

// need XmlDocRoot tag or whatever to parse it properly

try {

s = ConvertXmltoObj(xml);

happyPathStatement(s);

happyPathGuarantor(s);

happyPathAging(s);

happyPathEncounters(s);

happyPathEncounterCharges(s);

} catch (JAXBException e) {

e.printStackTrace();

fail();

} catch (ParserConfigurationException e) {

e.printStackTrace();

fail();

} catch (SAXException e) {

e.printStackTrace();

fail();

} catch (IOException e) {

e.printStackTrace();

fail();

}

assertTrue(true);

}

更新:

删除了的.class,所以命令是这样的:

java -cp .:/path/junit-4.8.1.jar org.junit.runner.JUnitCore HappyPath

获得现在这个错误:

JUnit version 4.8.1

Exception in thread "main" java.lang.NoClassDefFoundError: HappyPath (wrong name: com/xxx/xxx/datamodel/ge/HappyPath)

at java.lang.ClassLoader.defineClass1(Native Method)

2015-09-22

Rob

+1

抛弃'.class'。 –

+1

使用类似maven或gradle的东西来构建您的项目。它带有junit支持,因此您可以轻松运行测试。 –

+0

谢谢,现在得到它:JUnit版本4.8.1 线程“main”中的异常java.lang.NoClassDefFoundError:HappyPath(错误名称:com/xxx/xxx/datamodel/ge/HappyPath) \t at java.lang.ClassLoader .defineClass1(本地方法) –

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值