MS Visual Studio 2010 SP1.
I have wrote some class. Then I have wrote unit tests for it. Please, look at the my first screen:
If I run unit test via "1" button, then a code works as I have expect, but if I run unit test via "2" button, then I have unexpected behavior. Please, look at the my second screen:
When the condition
if (null == acadRegistryKey)
is true, I press the F10 key and go to row number 175. I press F10 key again, and... I go to row number 177. Why it happens??? After row number 175 I must have return from method, because exception must occur.
Best Regards,
Andrey
Related
The topic says it all. Sometimes i just want to take a quick look and then continue, especially when a code line get hit several times. Can i automate the press-manually-f5-to-continue-after-a-second?
Right click on a breakpoint an select "When Hit...":
You can run a macro like this:
Sub Sleep1s()
System.Threading.Thread.Sleep(1000)
End Sub
Or you can call 11 times {System.Threading.Thread.Sleep(90)} in the message. (Because VS debugger doesn't allow for expression to run for more than 100 ms).
But sleeping this way will block the main IDE UI thread. I don't know is it acceptable for you.
I'm using MSTest with Visual Studio 2012, is it possible to see which test runs first, second third and so forth?
I prefer the tests to run in random orders but I just want to know when tests fail, I like to know the sequence they ran and helps me to figure out why they fail easier.
If you want to know the sequence in which your test ran you can do the following:
A bit of work to do:
Add a breakpoint at the start of your method decorated with attribute 'TestMethod'.
Right click your breakpoint and select 'When Hit...'.
Make sure the checkbox next to 'Print a message' is ticked.
Do this for all your test methods.
Let Visual Studio do the rest:
Debug all your tests by pressing ALT + S, D, A.
Wow! It worked:
Find the sequence in your debug output window (ALT + V, O).
There are two different concepts
Coded UI Test - Mostly automation will be in done in these test
MS Test - Mostly unit tests will be written here
Its not possible to run MSTest in order even if you define .playlist file these will never run in sequence.
However in CodedUI case you will use and create Ordred list.
So the answer is NO. The reasoning behind that is - these are unit test case and all the unit test cases are meant to be executed independently.
I was debugging my code and thought about a possibility of automatic stepping over or Step into line by line in the xCode debug mode. It would be more efficient to see the way the code will be executed line by line without clicking for every next step. Maybe theres a way you can set a timer for every next step.
I was searching for something like that but there are too many posts for the debug mode which just explain the basic stuff.
Maybe I'm not understanding the question, but the three key buttons are:
- "Step over", F6, continuing execution but stopping at the next line of code (but not single stepping through the method that the current line of code references);
- "Step into", F7, continuing execution but stopping at the first line of code in the method your current line of code references;
- "Step out", F8, continuing execution but stopping at code that called current method.
See Control Program Execution of the Xcode Users Guide.
The other obvious technique is judicious use of setting breakpoints or setting "watch point" (i.e. have the debugger automatically pause whenever a particular variable changes).
Probably worth seeing Debugging in Xcode WWDC 2012 video
I have a method that is executed multiple times (reading data from a database) and now I need to debug a code that executes this method and it seems that it is executed until it reads all rows from the table (1000+) I just want to let the program execute this method and continue with the debugging from there.
Just to be more specific - in debug mode I use F11 to go through the code and this behavior is frustrating. I don't want to change my break point, just want to let this method executes itself, but the only way I know for now is pressing F5 which executes everything not just the current method.
Two options:
1. Press Shift+F11 to step back out of the function
2. Once you have stepped into the function, insert another breakpoint immediately after the loop, then press F5 to skip to that breakpoint.
You can decorate your method with [DebuggerStepThrough]
Instead of using Step Into (F11) Use - Step Over (F10)
and if you've already entered the function (because you pressed F11) you can always Step Out using Shift + F11
For more information see Mastering Debugging in Visual Studio 2010
I have a simple loop code, and try to debug it. Imagine there is 100 step in my code(a counter cont it). is it possible in VS2010 that for example I trace step 1 and 2 and then ignore the rest until 90,again start debugging from 90 to 100?
I know that I can use an if condition in my code, but can VS 2010 handle such this scenario?
press right click near the breakpoint
you will see
hit count...
condition...
etc.
you can use this to control the break point