.NET Conditional Compiler Symbols and Unit Test Libraries -


My team has a set of unit testing libraries that run against our application code - unfortunately they are throwing exceptions (unexpected) exceptions. The reason for this is that our logging code is being called and the items have not been setup. The logging code has been implemented through a method attribute, which we have setup using PostSharp (which is said before and after the method body). This feature should not be called.

Here is where PostSharp helps us out: it searches for a conditional compiler directive (SIPPOSSTSHRAP) which asks for it not to be executed. In other words, if we define the instruction, while the unit tests are executed, then we can independently examine the desired code with the logging aspect - on the way, avoiding unnecessary dependencies and complex joke codes successfully.

This is great! Except for a catch ... a conditional compiler directive defined for our test project is not being defined for the project - which means that under the test our code still uses the attribute and all of us Tests fail.

Is it possible to define the compiler directive in the entire solution while running a unit test? Even if we are not implementing it in the entire solution, can we apply to a specific project, when we are running unit tests (this will work equally)?

I am also interested in seeing opinions about this approach (We are trying to achieve separation and scalability through AOP code, but we are likely to have some extra hoops which we Jump through progress).

Note: I am not speaking the integration test here, just test the unit. We only want to test the specific unit and we do not care whether the logging code works or not - which is tested by other unit tests (which is fine).

I would suggest creating a special build configuration for testing, perhaps there are some ways to find out that Whether a unit is created due to unit tests (possibly some MSBilled property) being executed, but it would be incredible in incremental build scenarios.


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -