While trying to create a unit test for a particular method, we are getting a .cs file with no content. RRS feed

  • Question

  • Hi we are trying to write unit tests for our methods to get the code coverage. We are using visual studio 2008 developers edition. When we right click the method and choose create unit tests, select the test project and click OK. It does say generating tests and opens the .cs test file but the file has no content like test class and test methods, It is blank.

    The output window shows "Object reference not set to an instance of the object". We are not sure why this is happening and where the problem lies.

    Thank You


    • Moved by eryang Thursday, May 5, 2011 3:29 AM (From:Visual Studio Code Analysis and Code Metrics)
    Wednesday, May 4, 2011 11:03 AM


All replies

  • Move to VSTS forum for better support.
    Eric Yang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, May 5, 2011 3:29 AM
  • Hi,

    You need to check a classe, method, etc in the unit test generation wizard. Please refer http://msdn.microsoft.com/en-us/library/ms379625(v=vs.80).aspx



    Friday, May 6, 2011 6:11 AM
  • Hi,

    Thank You for the suggestion. I was selecting the method in the wizard and the .cs file generated had the nameofthemethodTest.cs but with no body in it.

    Later we figured out that there were some problems in building the project, though there was no error  indicated when solution was build, But when we tried do a clean and build on the inidividual items, it threw some errors, After correcting the errors we were able to create the unit tests.




    Friday, May 27, 2011 6:16 AM