Ask a questionAsk a question
 

AnswerUnit testing an exporter

  • Thursday, November 05, 2009 2:23 PMrms2219 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    So I have an application that exports data to either a spreadsheet or as a CSV file. My question is, as I am in the process of writing unit tests for the application, how would one test something so "visually dependent" as the export process?  What kind of "asserts" could be made?  I wouldn't want to import after exporting and compare the data as that defeats the whole purpose of a unit test.
    • Moved byChris SchmichMSFTThursday, November 05, 2009 8:44 PMThis is a unit-testing-specific question. (From:Visual Studio Performance Tools (Profiler))
    •  

Answers

  • Friday, November 06, 2009 10:02 AMEdwer FangMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hello rms2219,

    Based on your description, you want to write a unit test for the application, the unit test could verify the data which you will export to outer file. Unfortunatelly, I think this defeats the purpose of unit test. As unit tests check for logic errors in the methods of classes with comparing the returned value of methods to the expected value to find whether there exists errors.

    However, maybe you could create a new method to do this kind of testing. You may refer to the example mentioned in this article to see if it helps.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Send us any feedback you have about the help from MSFT at fbmsdn@microsoft.com.
    • Marked As Answer byrms2219 Friday, November 06, 2009 1:05 PM
    •  

All Replies

  • Friday, November 06, 2009 10:02 AMEdwer FangMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hello rms2219,

    Based on your description, you want to write a unit test for the application, the unit test could verify the data which you will export to outer file. Unfortunatelly, I think this defeats the purpose of unit test. As unit tests check for logic errors in the methods of classes with comparing the returned value of methods to the expected value to find whether there exists errors.

    However, maybe you could create a new method to do this kind of testing. You may refer to the example mentioned in this article to see if it helps.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Send us any feedback you have about the help from MSFT at fbmsdn@microsoft.com.
    • Marked As Answer byrms2219 Friday, November 06, 2009 1:05 PM
    •