Can AppHarbor set a conditional compilation symbol during build?

ぃ、小莉子 提交于 2019-12-10 21:27:55

问题


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.


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/9389673/can-appharbor-set-a-conditional-compilation-symbol-during-build

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