xUnit.net Test Stripper [to remove test code embedded in binaries prior to deployment/shipping]

强颜欢笑 提交于 2020-01-03 05:19:12

问题


Is there a Test Stripper (as defined in xUnit Test Patterns) available that supports removing classes containing methods tagged as [Fact]s etc. plus the dependency on xunit.dll from binaries [as part of a build process] ?

Further details of the full requirements and context are at this xUnit CodePlex post.

Failing that (something that removes the tests and the reference to the DLL), does anyone have a utility/proven clean approach to removing the xunit.dll dependecy without too much monkeying around in .vcproj files etc.

Open source preferred. A cleanly written one for NUnit might potentially serve as a base.

NB: I'm aware of the negatives of embedding code into assemblies - this question isnt about that (unless you feel after reading the codeplex thread that some key points are being missed).


回答1:


If your unit tests are placed in a project resp. assembly of their own there should be no need to strip test classes prior to deployment. What's wrong about this approach?




回答2:


As noted in the codeplex post where I specified the requirements, I implemented a basic stripper with Mono.Cecil but ended up leveraging the fact that unused references get optimised out in a release build to 'strip' tests out by excluding them based on a #define, which I control from outside via the MSBuild invocation



来源:https://stackoverflow.com/questions/1443278/xunit-net-test-stripper-to-remove-test-code-embedded-in-binaries-prior-to-deplo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!