Unit test to XML file

This is a discussion on Unit test to XML file within the Tech Board forums, part of the Community Boards category; I have a complete project, with several unit test, coded in C++. I need to get the results of these ...

  1. #1
    Registered User
    Join Date
    Sep 2007
    Posts
    4

    Question Unit test to XML file

    I have a complete project, with several unit test, coded in C++. I need to get the results of these unit test to print out to an xml file but I have no idea where to start

    any help?

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,506
    Do you have any idea what the XML file is supposed to look like, for example element and attribute names.

    Moved to tech.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Sep 2007
    Posts
    4
    No, but I think all that can be very flexible.
    I just dont know what I need to do to get it there. Do I need something in each unit test file (there are over 100) or do I need to write a new file with specific instructions to run the unit test and print them to an XML file (wouldnt know exactly how to do that because I also need to print out whether the test pass/fail).
    Or is there some easier way?

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    That would depend on several things:
    What do you want from the test-case, to go into the XML file - perhaps just which test and success/fail, if so, what else?
    Are the test-cases currently creating files that you may translate into XML?

    These are just some of the questions that we'd have to know the answer to, to be able to help properly.

    --
    Mats

  5. #5
    Registered User
    Join Date
    Sep 2007
    Posts
    4
    For right now all I need is the tests that fail. These test are not creating any files or are being output to any file. When I run the program the tests are displayed in a list format and I can choose to run one individually or all of them. My problems are; I do not know how to get the results of each unit test without manually running the program and then how to get those results to any/xml file.

  6. #6
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    So how do you (or perhaps more correctly, the test-framework) know if the test succeeded or failed? If this is not in a file, then you'll need to use the framework to store the result in the file. Or change each test to generate a success/fail entry in a file - but if that's not part of the current unit test, then it's pretty meaningless to change the test itself. Don't the tests say WHAT failed somehow - that tends to be useful for troubleshooting the relevant fix.

    --
    Mats

  7. #7
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,506
    Well without some idea as to what you're going to do with the XML file once you've got it, it could be something simple like putting <test></test> around the body of each test results file.

    Or perhaps you're after something like
    <test file="file1.txt" result="pass" />
    <test file="file2.txt" result="fail" />

    To me, this just seems like Perl to extract the required information, with some formatted output.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  8. #8
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Salem, I too, was thinking that Perl would be a good choice here... [Not particularly original thinking, of course].

    --
    Mats

  9. #9
    Registered User
    Join Date
    Sep 2007
    Posts
    4
    I need the xml file becuase I am using CruiseControl ( dont know if you are familiar with) but it is continuous integration where my project is run/compiled everytime it is updated. After running it only shows the files that failed to compile, but it also has the capability to show unit test results by including the xml file of unit test results

    I do have test fixutres for the unit test and it does output what failed but not to a file. As for perl- that i have no idea about

    any ideas?

  10. #10
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,506
    Ask your co-workers who've been using the system longer than you have?

    Look at examples of what you have (test results, compilation logs, whatever) and then look at example XML files which were derived.

    You've got all the information, or at least the ability to find it out. All we can do is make fairly general suggestions about how might be the best way of processing all the text information you have into something you want.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. opening empty file causes access violation
    By trevordunstan in forum C Programming
    Replies: 10
    Last Post: 10-21-2008, 11:19 PM
  2. Replies: 3
    Last Post: 03-04-2005, 01:46 PM
  3. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 09:46 AM
  4. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21