lundi 1 février 2016

Make resource xml configurable, while make tests in java?

I have to test over 100+ different situations and for every one I need external xml which to be read and parsed. I use:

String xml = IOUtils.toString(
                this.getClass().getResourceAsStream(path),encoding);

For example my test xml:

<container xmlns:dmc="http://ift.tt/1m7UxGh">
    <object id="1369" checkedParamter="in" class="Class1">
...

</object>
</container>

But I have to test with ivalid id , with missing id, with existing id. Then I need checkedParamter to have 3-4 values and to combine all the combinations with id attribute. For every test now I create new xml and the only difference is is these two attributes id and checkedParamter. I wonder if there is easy way to read the xml and to use the same structure but to pass these values from my test.

 <container xmlns:dmc=" http://ift.tt/1m7UxGh">
        <object id= ${valueId} checkedParamter=${valueChechedParamter} class="Class1">
    ...

    </object>
    </container>

Then I will use one xml and will put the desire values at the beginning of the test. I do not technology or way to do that?

Aucun commentaire:

Enregistrer un commentaire