views:

42

answers:

2

I have visual studio 2010, and a unit-test project.
when i run (debug test in the current context),then stop it,and then change the code,

i have to rebuild the project, otherwise the project will run without debugging, and it will use the old code !!!

why is that happening ?

A: 

Because the tests needs a compiled version of the code, since they need to execute your code to test whether it works or not.

Edit: in my environment, the test project is in the same solution. Running the test will automatically rebuild the project.

Peter van Kekem
+1  A: 

When you 'run' the code you are running a compiled executable. When you change the code this does not change the compiled executable (i.e. you have to 'rebuild' it).

Marm0t
This assumes that the tested code is statically linked to the test-code. The OP is asking why he has to rebuild the test project.
Space_C0wb0y
even if the code was dynamically linked wouldn't he still need to recompile the code for the object he changed?
Marm0t
Ok, Marm0t but can it be just as simple as the ordinary project?? i mean you can change the code while your debugging?and BTW i mean change the test code, not the tested code.
Nour Sabouny