Test code option in VS2010
Is it possible to execute code quick test in VS2010?
For example I would like to test code below just selecting it in code editor and execute it by passing variables?
public static int GetInt(object value)
{
int result;
Int32.TryParse(GetString(value), out result);
return r开发者_如何学JAVAesult;
}
I know about Immediate Window but it does not always works and not all code can be tested with it.
No.
Instead, you can copy-paste the code into LINQPad and execute it there.
You could do this by running the corresponding unit test you wrote before implementing the method. This will ensure that the implementation you just wrote conforms to the expected results you defined in the unit test.
Try one of these tools:
- LINQPad: http://www.linqpad.net/
- Snippet Compiler: http://www.sliver.com/dotnet/SnippetCompiler/
There is an extension for Visual Studio 2010 called Code Scrap which, according to the developer, "Adds a window for writing and executing scraps of code within Visual Studio."
精彩评论