当前位置: 首页 > news >正文

太原seo网站优化戴尔网站建设成功的关键

太原seo网站优化,戴尔网站建设成功的关键,在linux系统上用什么做网站,建筑人才网有哪些JUnit5最终版本即将来临 #xff08;当前是M4#xff09;#xff0c;我已经开始研究如何编写扩展。 在JUnit5中 #xff0c;您没有使用Runners #xff0c; Rules #xff0c; ClassRules等#xff0c;而是只有一个Extension API来实现自己的扩展。 JUnit5提供了多个接… JUnit5最终版本即将来临 当前是M4我已经开始研究如何编写扩展。 在JUnit5中 您没有使用Runners Rules ClassRules等而是只有一个Extension API来实现自己的扩展。 JUnit5提供了多个接口来挂钩其生命周期。 例如您可以挂钩到“ 测试实例后处理”以在测试实例上调用自定义初始化方法或者通过“ 参数解析”来在运行时动态解析测试方法参数。 当然到目前为止典型的操作如在执行所有测试之前执行测试之前执行测试之后进行挂接等等可以在http://junit.org/junit5/docs/找到完整列表。 当前/用户指南/extensions-lifecycle-callbacks 但是在每个过程中都在过程的哪一点执行 为了测试它我刚刚创建了一个扩展该扩展实现了所有接口并且每个方法都会打印出谁。 public class LoggerExtension implements TestInstancePostProcessor, ParameterResolver, BeforeAllCallback,BeforeEachCallback, BeforeTestExecutionCallback, AfterEachCallback, AfterTestExecutionCallback, AfterAllCallback,TestExecutionExceptionHandler {Overridepublic void postProcessTestInstance(Object testInstance, ExtensionContext context) throws Exception {System.out.println(Test Instance Post-processing called);}Overridepublic boolean supports(ParameterContext parameterContext, ExtensionContext extensionContext)throws ParameterResolutionException {System.out.println(Parameter Resolver Supports called);return parameterContext.getParameter().getType().equals(String.class);}Overridepublic Object resolve(ParameterContext parameterContext, ExtensionContext extensionContext)throws ParameterResolutionException {System.out.println(Resolver called);return Hello World;}Overridepublic void beforeAll(ContainerExtensionContext context) throws Exception {System.out.println(Before All called context.getTestClass().get());}Overridepublic void beforeEach(TestExtensionContext context) throws Exception {System.out.println(Before Each called);}Overridepublic void beforeTestExecution(TestExtensionContext context) throws Exception {System.out.println(Before Test Execution called);}Overridepublic void afterEach(TestExtensionContext context) throws Exception {System.out.println(After Each called);}Overridepublic void afterTestExecution(TestExtensionContext context) throws Exception {System.out.println(After Test Executon called);}Overridepublic void afterAll(ContainerExtensionContext context) throws Exception {System.out.println(After All called);}Overridepublic void handleTestExecutionException(TestExtensionContext context, Throwable throwable) throws Throwable {System.out.println(Test Execution Exception called);throw throwable;} } 然后我创建了一个包含两个测试的JUnit5测试套件 ExtendWith(LoggerExtension.class) public class AnotherLoggerExtensionTest {Testpublic void test4() {System.out.println(Test 4);}}ExtendWith(LoggerExtension.class) public class LoggerExtensionTest {Testpublic void test1() {System.out.println(Test 1);}Testpublic void test2(String msg) {System.out.println(Test 2 msg);}Testpublic void test3() {System.out.println(Test 3);throw new IllegalArgumentException();}}RunWith(JUnitPlatform.class) SelectClasses({LoggerExtensionTest.class, AnotherLoggerExtensionTest.class}) public class LoggerExtensionTestSuite { } 那么在执行此套件之后输出是什么 让我们来看看它。 请注意出于可读性考虑我在终端输出上添加了一些标注。 Before All called class AnotherLoggerExtensionTest Test Instance Post-processing called Before Each called Before Test Execution called Test 4 After Test Execution called After Each called After All called// 1Before All called class LoggerExtensionTest Test Instance Post-processing called Before Each called Before Test Execution called Test 1 After Test Execution called After Each called// 2Test Instance Post-processing called Before Each called Before Test Execution called Parameter Resolver Supports called Resolver called Test 2 Hello World After Test Execution called After Each called// 3Test Instance Post-processing called Before Each called Before Test Execution called Test 3 Test Execution Exception called After Test Execution called After Each called// 4After All called 1运行它的第一个测试是AnotherLoggerExtensionTest 。 在这种情况下只有一个简单的测试因此扩展的生命周期为BeforeAll Test Instance-Post-Processing Before Each Before Test Execution 然后执行测试本身然后执行所有After回调。 2然后执行LoggerExtensionTest 。 第一次测试不是参数化测试因此不会调用与参数解析有关的事件。 在执行test方法之前将调用测试实例后处理 然后再引发所有事件之前。 最终所有后续事件都将执行测试。 3第二个测试包含需要参数解析。 参数解析器在Before事件之后和执行测试本身之前运行。 4最后一次测试将引发异常。 在执行测试之后但在After事件之前调用Test Execution Exception 。 最后要注意的是 BeforeAll和AfterAll事件是按测试类而不是套件执行的。 本示例中使用的JUnit版本是org.junit.jupiterjunit-jupiter-api5.0.0-M4 翻译自: https://www.javacodegeeks.com/2017/06/lifecycle-junit-5-extension-model.html
http://www.zqtcl.cn/news/524152/

相关文章:

  • 建设报名系统是正规网站吗计算机培训班出来好找工作吗
  • 网站上的文章用秀米可以做吗宁波外客网络科技有限公司
  • 网站底部导航代码成品视频直播软件推荐哪个好一点ios
  • 上海电商网站开发公司垫江网站建设价格
  • 门户网站建设存在问题与不足商城网站开发项目文档
  • wordpress建站方便吗wordpress加入海报功能
  • 网站名称注册保护2018wordpress主题
  • 类似享设计的网站企业信息系统公示
  • 如何学习网站开发酒店网站源码
  • 怎么用nas做网站服务器WordPress云虚拟空间
  • 网站设计 ipad企业品牌推广宣传方案
  • 织梦网站怎么更换模板济南建设厅网站
  • 用wordpress仿站专业做俄语网站建设司
  • 做暧暧网站网站开发 思维导图
  • asp.net做登录注册网站苏醒的wordpress主题怎么样
  • 正能量不良网站推荐2020网站建设单位是什么
  • 固镇网站建设郑州网站seo顾问
  • 新建定制网站费用公司网站手机端和电脑端
  • 网站域名注册地址苏州建设培训中心网站
  • 高端娱乐网站建设沈阳seo专业培训
  • 做播放器电影网站需要多少钱6广州seo公司推荐
  • 笔记本可以做网站吗怎样查看网站是否备案
  • 千灯做网站网站静态和伪静态意思
  • 做境外碎片化旅游的网站wordpress wdcp
  • 整容医院网络建设公司seo实战技术培训
  • 免费服务器建立网站郑州seo线上推广系统
  • 医院网站建设的目的qq小程序源码
  • 郑州seo网站排名优化公司建站行业发展
  • 彭山住房和城乡建设局网站儒枫网网站建设
  • wap asp网站模板下载中企动力骗子公司