AppHarbor 可以在构建期间设置条件编译符号吗? [英] Can AppHarbor set a conditional compilation symbol during build?

查看:29
本文介绍了AppHarbor 可以在构建期间设置条件编译符号吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

AppHarbor 可以在构建期间设置条件编译符号吗?也许只是:AppHarbor

Can AppHarbor set a conditional compilation symbol during build? Maybe simply: AppHarbor

我有一些无法在服务器上运行的测试(它们依赖于测试数据文件).

I have some tests that can't run on the server (they rely on test data files).

如果 AppHarbor 可以设置条件编译符号,那么当该符号存在时,我可以在测试中添加 [Ignore] 属性.

If AppHarbor could set a conditional compilation symbol, then I could add an [Ignore] attribute on the test when that symbol is present.

或者,在 AppHarbor 上运行时,是否有更好或不同的方法来忽略特定测试?

Or, is there a better or different way to ignore specific tests when running at AppHarbor?

或者,有没有办法让测试代码正确引用驻留在项目中的测试数据文件?

Or, is there a way for the test code to correctly reference a test data file residing in the project?

谢谢!格伦

我通过将数据文件作为资源嵌入到测试项目中来使我的测试工作.不理想,但现在还好.但是,还是想知道编译符号是否可以像描述的那样设置.

I got my test to work by embedding the data file as a Resource in the test project. Not ideal, but okay for now. However, would still like to know if compilation symbols can be set as described.

推荐答案

设置AppHarbor"编译符号是一个有趣的建议,但目前在 AppHarbor 上不支持.您可能希望将其添加为功能请求.

Setting an "AppHarbor" compilation symbol is an interesting suggestion, but it's not currently supported on AppHarbor. You might want to add it as a feature request.

运行测试时,Environment appSetting 设置为 test.您可以有条件地使用它来跳过某些测试.如果您更喜欢拥有自己的配置,您可以使用 Web.Test.Config 文件来应用任何必要的转换,以便您确定是否应该运行测试.

When running your tests the Environment appSetting is set to test. You could use that conditionally to skip certain tests. If you prefer to have your own configuration you could use a Web.Test.Config file to apply any necessary transformations that'll allow you to determine whether tests should be run or not.

这两种方法都在这篇文章中进行了描述.

Both approaches are described in this article.

通常我的建议是避免依赖运行测试时不存在的文件.这也将使应用程序在任何 CI 环境中工作.将文件作为您描述的嵌入资源包含是一个选项,但也应该可以将它包含在您的项目中,并将 Build Action 属性设置为 Content 并且它将在输出目录中可用.

Generally my recommendation would be to avoid relying on files that are not present when running tests. That'll also make the application work in any CI environment. Including the file as an embedded resource as you describe is an option, but it should also be possible to include it in your project with the Build Action property set to Content and it'll be available in the output directory.

这篇关于AppHarbor 可以在构建期间设置条件编译符号吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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