命令行执行Junit测试

原创 2016年05月31日 15:00:43

【0】README

0.1)本文旨在给出如何在命令行中执行 Junit测试的steps:


【1】在命令行中执行Junit测试

1)problem+solution:

1.1)problem:



1.2)solution:导出 JUnitCore 类并且使用 runClasses() 方法,将测试类名称作为参数。

package com.spring.chapter3_scope;

import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
import org.junit.runner.notification.Failure;

public class TestRunner {
	public static void main(String[] args) {
		Result result = JUnitCore.runClasses(StudentTest.class);
		for (Failure failure : result.getFailures()) {
			System.out.println(failure);
		}
	}
}


2)开始测试



Attention)在命令行中需要导入 相应的Junit jar ,参见:  https://github.com/pacosonTang/SpringInAction/tree/master/chapter3/chapter3_scope

E:\bench-cluster\cloud-data-preprocess\SpringInAction4\src>java -cp .;../lib/*; com.spring.chapter3_scope.TestRunner
五月 31, 2016 2:39:06 下午 org.springframework.test.context.support.AbstractTestContextBootstrapper getDefaultTestExecutionListenerClassNames
信息: Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.test.context.web.ServletTestExe
cutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.support.Depe
ndencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.t
ransaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener, org.springframework.test.context
.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.c
ontext.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframe
work.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener]
五月 31, 2016 2:39:06 下午 org.springframework.test.context.support.AbstractTestContextBootstrapper instantiateListeners
信息: Could not instantiate TestExecutionListener [org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener]. Specify custom listener cla
sses or make the default listener classes (and their required dependencies) available. Offending class: [org/springframework/transaction/interceptor/T
ransactionAttribute]
五月 31, 2016 2:39:06 下午 org.springframework.test.context.support.AbstractTestContextBootstrapper instantiateListeners
信息: Could not instantiate TestExecutionListener [org.springframework.test.context.web.ServletTestExecutionListener]. Specify custom listener classes
 or make the default listener classes (and their required dependencies) available. Offending class: [javax/servlet/ServletContext]
五月 31, 2016 2:39:06 下午 org.springframework.test.context.support.AbstractTestContextBootstrapper instantiateListeners
信息: Could not instantiate TestExecutionListener [org.springframework.test.context.transaction.TransactionalTestExecutionListener]. Specify custom li
stener classes or make the default listener classes (and their required dependencies) available. Offending class: [org/springframework/transaction/int
erceptor/TransactionAttributeSource]
五月 31, 2016 2:39:06 下午 org.springframework.test.context.support.AbstractTestContextBootstrapper getTestExecutionListeners
信息: Using TestExecutionListeners: [org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@28864e92, org.springframe
work.test.context.support.DependencyInjectionTestExecutionListener@6ea6d14e, org.springframework.test.context.support.DirtiesContextTestExecutionListe
ner@6ad5c04e]
五月 31, 2016 2:39:06 下午 org.springframework.context.support.AbstractApplicationContext prepareRefresh
信息: Refreshing org.springframework.context.support.GenericApplicationContext@2812cbfa: startup date [Tue May 31 14:39:06 CST 2016]; root of context
hierarchy
name = tr, age = 100 // highlight line.


版权声明:本文为博主原创文章,未经博主允许不得转载。 举报

相关文章推荐

Windows&Linux 命令行运行JUnit

Windows 方式1: step a:先set classpath,即工程所引用的jar包和其他工程,注意case所在工程本身也要加入classpath set CLASSPATH=C:\JDeve...
  • tochal
  • tochal
  • 2013-09-25 10:50
  • 8856

解决单元测试时报Could not instantiate问题

解决单元测试时报Could not instantiate appender named "LFS".问题,原因:缺少log4j配置文件。
  • hfhwfw
  • hfhwfw
  • 2015-08-06 07:27
  • 1552

我是如何成为一名python大咖的?

人生苦短,都说必须python,那么我分享下我是如何从小白成为Python资深开发者的吧。2014年我大学刚毕业..

mybatis+springmvc测试出现的奇怪问题

mybatis+springmvc测试出现的奇怪问题

命令行中运行junit类

转自http://www.etwiki.cn/linux/8717.html 做过的项目一般都是在eclipse和ant里面跑的,今天要跑个小测试,单独写个ant就没必要了,查了下命...

Spring基于注解TestContext 测试框架使用详解

Spring基于注解TestContext 测试框架使用详解,代码下载地址:http://www.zuidaima.com/share/1775574182939648.htm

Xcode命令行执行单元测试

xcodebuild命令行执行单元测试
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)