Here is a bit of context:

I am practicing TDD for a new application that will target .NET 3.5 CF and .NET 4.5.2 FF.

I might have some part of the code that use polymorphisme to decide at run-time a strategy (the design pattern) to use while running on a .NET 3.5 CF machine and an another running on a .NET 4.5.2 FF machine. Both version are in different solution and code files are added as links as to not "duplicate the code". This is out of my control since it was a corporate decision made above me and I have to live with it.

My question is:

Should I add a test project to both the FF version and the CF version (by adding the test cases files as links in the CF solution to be able to run these in CF) or if everything is tested in FF I can assume the CF half is OK?


I know the "two solutions" part might not be the best way to go, but this is what I have to work with.

  • Do you know that .NET 4.5 can run .NET 3.5 code?
    – user113093
    Commented Nov 30, 2016 at 0:44
  • @Hosch250 Yes I know, but the production environnement cannot run .NET 4.5. I have 2 production environnement one in 4.5, the other in 3.5. I have build scripts that builds the project and run the tests for both. But I was wondering if I had to run the tests for my 3.5 script. But just as Bart van Ingen Schenau said in is answer I will do the 3.5 tests only if the risk is high enough.
    – Sebastien
    Commented Nov 30, 2016 at 15:22
  • @Sebastien what Hosch (and I) are saying is that 4.5 can run 3.5 code. There would really have to be a very compelling reason to compile against 4.5. You can run your 3.5 version in the 4.5 environment.
    – RubberDuck
    Commented Nov 30, 2016 at 16:14
  • To that point, if you're doomed to link code files like this, you're much more at risk to break the 3.5 code with features that are only available in 4.5. Test the 3.5 code if you can only afford to test one.
    – RubberDuck
    Commented Nov 30, 2016 at 16:16
  • 2
    Just write a single 3.5 version. It will run in 4.5 just the same.
    – user113093
    Commented Nov 30, 2016 at 17:19

3 Answers 3


Stop linking the code files.

Instead, start extracting the shared files into actual class libraries that target 3.5. If you're already sharing them between projects, then they must already compile with that version of the compiler. Remember, you can always reference a library built against an older version of the framework.

Stop the insanity. Will anyone actually know that you did the right thing and created class libraries instead? You say this is a new project, there's no reason to create a mess like this on day one.

  • I like where your going, but unfortunately I cannot change this as it is one of the corporate decisions I was saying I had to live with... In fact I like @Bart van Ingen Schenau 's answer but I guess technically you have the right answer.
    – Sebastien
    Commented Nov 30, 2016 at 15:26
  • Do you have influence over any sympathetic ears @Sebastien? Who actually made these "corporate" decisions? Ultimately, a corporation is still just a bunch of people.
    – RubberDuck
    Commented Nov 30, 2016 at 16:11
  • I do not have much influence since I've been hired recently.
    – Sebastien
    Commented Nov 30, 2016 at 19:40

If there are (expected to be) files that are specific for one of the supported platforms or features that intentionally behave differently on the different platforms, then you should definitely test those parts on both platforms.

Besides that, it is a question of effort versus risk if you want to test the rest on both platforms or just on one of them.

  • 2
    'effort versus risk' the famous last words of every manager.
    – Bent
    Commented Nov 29, 2016 at 18:04

As you know your solution will target at least two different platforms 3.5 and 4.5.2 you need to make sure all your test cases addresses both platforms.

If one or more tests are dependent on a specific platform, you'll have to make sure there is a similar test on the other platform.

Especially you need further test cases to make sure that code made towards 4.5.2 does not interfere with code made towards 3.5 and vice versa.

This is far from simple, it will take a lot of effort to make sure that you cover every difference between the two platforms.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.