locked
Data Driver Unit Test Example does not compile. RRS feed

  • Question

  • I found two examples of access an xls file and under 2008 they do not compile.

    int x= Int32::Parse(testContextInstance.DataRow["Arg1"].ToString());

    Both get an error "must have class/struct/union", both lines of code were taken from MSDN examples. Does anyone know whats wrong. Second issue the TextContext was define as "

    TestContext^ testContextInstance;"

    What does the ^ mean? I cannot find it in online documentation.

    Has the C++ language involved past my simple knowledge?

    Wednesday, March 20, 2013 9:00 PM

Answers

  • Hello,

    Thank you for your post.

    I did a research and find a thread about how to write a data driven unit test in C++:

    http://social.msdn.microsoft.com/Forums/en-US/vststest/thread/651692f1-9b14-470d-b2f3-24a7931c6bb3/

    David provided us detailed code which you can reference.

    What does the ^ mean? I cannot find it in online documentation.

    I am not C++ expert. I think that it is related to C++ language rather than a test issue. If you want to know the meaning, I suggest that you can consult your issue on Visual C++ General forum for better support.

    Based on David’s code, there is something wrong with this code: int x= Int32::Parse(testContextInstance.DataRow["Arg1"].ToString());.

    It should be like this: int a = Int32::Parse(TestContext->DataRow[0]->ToString());

    Best regards,


    Amanda Zhu [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Amanda Zhu Wednesday, March 27, 2013 1:31 AM
    Thursday, March 21, 2013 7:21 AM

All replies

  • Hello,

    Thank you for your post.

    I did a research and find a thread about how to write a data driven unit test in C++:

    http://social.msdn.microsoft.com/Forums/en-US/vststest/thread/651692f1-9b14-470d-b2f3-24a7931c6bb3/

    David provided us detailed code which you can reference.

    What does the ^ mean? I cannot find it in online documentation.

    I am not C++ expert. I think that it is related to C++ language rather than a test issue. If you want to know the meaning, I suggest that you can consult your issue on Visual C++ General forum for better support.

    Based on David’s code, there is something wrong with this code: int x= Int32::Parse(testContextInstance.DataRow["Arg1"].ToString());.

    It should be like this: int a = Int32::Parse(TestContext->DataRow[0]->ToString());

    Best regards,


    Amanda Zhu [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Amanda Zhu Wednesday, March 27, 2013 1:31 AM
    Thursday, March 21, 2013 7:21 AM
  • Hello,

    Since we haven't heard from you for a long time, I temporarily close this case. I mark useful reply as answer. If you have any concerns, please feel free to reopen it or submit a new question.

    Thanks for your understanding.

    Best regards,


    Amanda Zhu [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, March 27, 2013 1:31 AM