AppHarbor可以在构建过程中设置条件编译符号吗?

发布于 2025-01-08 02:10:20 字数 347 浏览 1 评论 0原文

AppHarbor可以在构建过程中设置条件编译符号吗?也许很简单:AppHarbor

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

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

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

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

谢谢! Glen

编辑:我通过将数据文件作为资源嵌入到测试项目中来使测试正常工作。不太理想,但目前还可以。但是,仍然想知道是否可以按照描述设置编译符号。

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).

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

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?

Thanks!
Glen

Edit: 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

自由如风 2025-01-15 02:10:20

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

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

本文中介绍了这两种方法。

一般来说,我的建议是避免依赖运行测试时不存在的文件。这也将使应用程序可以在任何 CI 环境中工作。正如您所描述的那样,可以选择将文件作为嵌入式资源包含在内,但也可以将其包含在您的项目中,并将 Build Action 属性设置为 Content 并且它将在输出目录中可用。

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.

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.

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.

困倦 2025-01-15 02:10:20

想要添加@runesorensen的答案:
您想要忽略其中的测试的每个测试项目都应该有 app.config 文件,否则“环境”应用程序设置将为空。

Want to add to the answer of @runesorensen:
Each test project, which you want to ignore tests in, should have app.config file, otherwise "Environment" app setting will be null.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文