0

I want to test my "engine" for a game, the engine generates xml messages for each run of the game , bellow there is a simplistic form of it. My method now is to take the xml each time, "parse" it, check the values i want with java(the game engine which generates the ticket is also in java), first i make an object almost with the same structure as the xml message and after for each message i do the checks, when i want to take statistics from all messages (millions per test) i have some public static variables to keep everything i want.

My question now is , is out there any faster or ready solution for this kind of testing ??

<?xml version='1.0' encoding='UTF-8' ?>
    < myCar="4" track="4" level="8"/>
    <params opponents="18,7,3,21,1,2,9" levels="5,7,4,8,6,5,6" startpo="8"/>
    <games>
    <game>
    <counter i="1" crash="3" turn="4"/>
    <counter i="2" crash="0" turn="12"/>
    .
    .
    <counter i="9" crash="3" turn="10"/>
    <counter i="10" crash="0" turn="3"  miniGame="2" win="0" r="5.5" p="99" />
    .
    .
    <counter i="50" crash="18" turn="2"/>
    </game>
    <aftergame>
    <counter="b1" ball="4" wins="0" />
    <counter="b2" ball="5" wins="0" />
    <counter="b3" ball="3" wins="0" />
    <counter="b4" ball="5" wins="0" />
    <counter="b5" ball="5" wins="1" />
    <counter="b6" ball="2" wins="0" />
    </aftergame>
    </games>

The checks i do is no duplicates at the cars, or that a win is indeed a win, ratio of when an after game is shown , or statistics pere level that the average turn is "this" and stuff like that

Thanks

fx86f
  • 69
  • 1
  • 10

1 Answers1

0

It sounds like you want to Validate the XML to see if a Value=Value or an Element only occurs X-Number-Of-Times. It also sounds like you may want to perform other complex checks.

You might want to consider validating the XML against one or more custom XSD Schemas. It is still work, but It could be easier than coding an Object each time! Maybe someone in your project already even made XSD for this?

If the XML shape and content should always follow certain rules, XML Schema Validation may be what you are looking for. Consider using an XSD Validator.

You can read more about XML Validtion. Search for "Cardinality" and "Simple Types"

LOOK HERE

DaFi4
  • 1,364
  • 9
  • 21
  • the xml messages are not sent anywhere, they generate locally and stay locally to be loaded from another java app, do you think that these programs are better for my time to test the message? I will add what kind o checks i do to original post – fx86f Jan 19 '16 at 12:31
  • try looking into XSD validation. You can define XSD text documents for testing instead of objects. – DaFi4 Jan 19 '16 at 12:57
  • sorry for delayed answer, the xml messages for each game are completely different they don't have a standard format – fx86f Mar 04 '16 at 09:27
  • I'm still thinking XSD validation might be the best way to go with these. You would want to make an XSD for each format type and convince your coworkers to keep the XSD updated as they make programming changes. These XSD can increase the quality of your products. http://stackoverflow.com/questions/751511/validating-an-xml-against-referenced-xsd-in-c-sharp – DaFi4 Mar 04 '16 at 12:37