命令行执行Junit测试
生活随笔
收集整理的這篇文章主要介紹了
命令行执行Junit测试
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
【0】README
0.1)本文旨在給出如何在命令行中執(zhí)行 Junit測試的steps:
【1】在命令行中執(zhí)行Junit測試
1)problem+solution:
1.1)problem:
1.2)solution:導出 JUnitCore 類并且使用 runClasses() 方法,將測試類名稱作為參數(shù)。
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 classesor 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.
總結
以上是生活随笔為你收集整理的命令行执行Junit测试的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 备案户无需预约可通行(备案户)
- 下一篇: img absolute 怎么居中(怎么