Unit Tests, Build Configuration and Internals

joerg

I am writing my UnitTests in a seperate Project from my Project under Test. To be able to test Internal classes/members I use the [InternalsVisibleTo] Attribute in my Project Under Test.

#if "BUILD_CONFIGURATION"
[assembly: InternalsVisibleTo("Tests_ProjectUnderTest")]
#endif

Following question arises:

Which Build configuration should I use for Unit Tests? The Internals shouldn't be visible in my released code, so #if RELEASE is not possible. On the other hand #if DEBUG doesn't really test what I want to release. Should you have a distinct UNIT_TEST-Configuration? Or how would/do you do this?

Tim Long

I don't usually make the [InternalsVisibleTo()] attribute conditional, since the internals are only ever made visible to the named assembly. You can beef up the security of that by strong-naming the assemblies, so then no-one can 'fake' your unit test assembly. However, if you're that concerned about this, you should probably be obfuscating your assemblies anyway, otherwise reverse engineering is trivial. I generally take the attitude that private/internal is a statement of intent and not a security feature, since it can always be circumvented using reflection.

I generally unit-test my debug configuration, because I want to see the diagnostic output in my unit test results. This may depend on which runner you use, I use the ReSharper runner and it captures debug/trace output into the unit test window. Since the trace verbosity is reduced in my release builds, I prefer to unit test the debug builds. I think this is a judgement call, though.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Unit tests not run by a "gradle build"

From Dev

MassTransit Service Bus Configuration and Unit Tests

From Dev

how to implement the unit or integration tests for logstash configuration?

From Dev

Karma configuration of unit tests of services with SignalR dependency

From Dev

Spring transactions in unit tests and annotation based configuration

From Dev

how to implement the unit or integration tests for logstash configuration?

From Dev

What is required for doing Unit Tests on a Build Server?

From Dev

Android Unit Tests failing for Debug build type

From Dev

Exception running unit tests with Fakes on build server

From Dev

Unit Tests Fails in Build Service But Not Locally

From Dev

How to build Fabric.js for unit tests

From Dev

TFS Build servers and critical Unit Tests

From Dev

Running unit tests before each build in Gradle

From Dev

What is required for doing Unit Tests on a Build Server?

From Dev

How to build Fabric.js for unit tests

From Dev

Running Xcode unit tests during release build

From Dev

TFS 2013 Build: Running Unit Tests in Parallel on multiple build agents

From Dev

How to access teamcity configuration parameters in MSBuild unit tests

From Dev

Maven surefire configuration for separating test into unit and integration tests fail

From Dev

Angular2 - configuration error while running unit tests with PhantomJS

From Dev

Is it normal to execute integration tests in the build machine on each build or just unit tests?

From Dev

Build C++ unit tests for C89 code

From Dev

Build and run unit-tests with two distinct jobs

From Dev

Running Unit Tests Fakes Framework on TFS build server | Error

From Dev

Gradle Android unit tests that depend on an 'aar' for build tool 0.11.+

From Dev

Using generated code in unit tests with maven clean build?

From Dev

Does build automation really help productivity even without unit tests?

From Dev

Can't build with scons my unit tests alongside with the program

From Dev

Run some unit-tests setup code locally, but not on the build server

Related Related

  1. 1

    Unit tests not run by a "gradle build"

  2. 2

    MassTransit Service Bus Configuration and Unit Tests

  3. 3

    how to implement the unit or integration tests for logstash configuration?

  4. 4

    Karma configuration of unit tests of services with SignalR dependency

  5. 5

    Spring transactions in unit tests and annotation based configuration

  6. 6

    how to implement the unit or integration tests for logstash configuration?

  7. 7

    What is required for doing Unit Tests on a Build Server?

  8. 8

    Android Unit Tests failing for Debug build type

  9. 9

    Exception running unit tests with Fakes on build server

  10. 10

    Unit Tests Fails in Build Service But Not Locally

  11. 11

    How to build Fabric.js for unit tests

  12. 12

    TFS Build servers and critical Unit Tests

  13. 13

    Running unit tests before each build in Gradle

  14. 14

    What is required for doing Unit Tests on a Build Server?

  15. 15

    How to build Fabric.js for unit tests

  16. 16

    Running Xcode unit tests during release build

  17. 17

    TFS 2013 Build: Running Unit Tests in Parallel on multiple build agents

  18. 18

    How to access teamcity configuration parameters in MSBuild unit tests

  19. 19

    Maven surefire configuration for separating test into unit and integration tests fail

  20. 20

    Angular2 - configuration error while running unit tests with PhantomJS

  21. 21

    Is it normal to execute integration tests in the build machine on each build or just unit tests?

  22. 22

    Build C++ unit tests for C89 code

  23. 23

    Build and run unit-tests with two distinct jobs

  24. 24

    Running Unit Tests Fakes Framework on TFS build server | Error

  25. 25

    Gradle Android unit tests that depend on an 'aar' for build tool 0.11.+

  26. 26

    Using generated code in unit tests with maven clean build?

  27. 27

    Does build automation really help productivity even without unit tests?

  28. 28

    Can't build with scons my unit tests alongside with the program

  29. 29

    Run some unit-tests setup code locally, but not on the build server

HotTag

Archive