命令列執行Junit測試
阿新 • • 發佈:2019-01-01
【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)開始測試
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 [email protected]28864e92, org.springframe
wor[email protected]6ea6d14e, org.springframework.test.context.support.DirtiesContextTestExecutionListe
[email protected]]
五月 31, 2016 2:39:06 下午 org.springframework.context.support.AbstractApplicationContext prepareRefresh
資訊: Refreshing [email protected] 12cbfa: startup date [Tue May 31 14:39:06 CST 2016]; root of context
hierarchy
name = tr, age = 100 // highlight line.