在Maven/surefire中,通过或不通过单元测试的好方法是什么? [英] What is a good way in maven/surefire to clean up after unit tests, whether they pass or not?

查看:60
本文介绍了在Maven/surefire中,通过或不通过单元测试的好方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不幸的是,我们有一些单元测试会创建内存映射的NIO文件,而这些文件无法被创建它们的进程删除(某些Windows问题).

We have some unit tests that unfortunately create memory-mapped NIO files that cannot be deleted by the process that created them (some windows issue).

无论如何,无论这些测试是否通过,我都希望对其进行某种形式的清理.我本来要在 prepare-package 阶段运行一个小的ant脚本,但是如果任何测试失败,那么surefire将立即退出.

Regardless, I would like to run some sort of clean up after these tests, whether they passed or not. I was going to run a small ant script at the prepare-package phase, but if any test fails, surefire exits immediately.

除了转到具有后测试阶段的 failsafe 插件之外,无论通过与否,有什么聪明的方法可以运行我的清理工作?

Apart from going to the failsafe plugin which has a post-test phase, is there any clever way I can run my cleanup regardless of pass or fail?

我怀疑不是-我已经遍历所有 surefire 配置选项...

I suspect not - I've gone through all the surefire config options...

内存映射的Nio文件无法删除同样的过程,甚至通过deleteOnExit.

edit: memory-mapped nio files cannot be deleted in the same process, even by deleteOnExit.

推荐答案

您应该将要执行的操作绑定到集成测试后生命周期阶段,该阶段随后由<一个href ="http://maven.apache.org/plugins/maven-failsafe-plugin/" rel ="nofollow"> maven-failsafe-plugin .如果您配置maven-clean-plugin这样做可能会起作用.

You should bound the thing you want to do into the post-integration-test lifecycle phase which is running afterwards the integration-test phase which is handled by the maven-failsafe-plugin. It might work if you configure the maven-clean-plugin to do so.

这篇关于在Maven/surefire中,通过或不通过单元测试的好方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆