Consider a scenario where I am testing a claims system. I want to submit quotes and check the total bill. Two or more claims in a day is supposed to earn me a bonus. So I need to check total amount after 1 claim, again after 2 claims, and then again after removing a claim and so on. The execution will be as below -
- Login
- Add 1 claim
- Calculate total receivable amount
- Add 1 more claim
- Calculate total receivable amount
- Remove a claim
- Calculate total receivable amount
- Logout
My TestNG.xml looks like this -
<test>
<classes>
<class name="Quotes">
<methods>
<include name="fLogin" />
<include name="fAddQuotes" />
<include name="fCheckTotal" />
<include name="fAddQuotes" />
<include name="fCheckTotal" />
<include name="fRemoveQuotes" />
<include name="fCheckTotal" />
<include name="fLogout" />
</methods>
</class>
</classes>
</test>
As mentioned, the function 'fCheckTotal' needs to be called multiple times in the same test. And I want to be able to push variable numbers of add/remove function in between.
But testNG is only executing the first occurence of the repeated methods (fAddQuotes, fCheckTotal).
Effectively the xml is doing this -
- Login
- Add 1 claim
- Calculate total receivable amount
- Remove a claim
- Logout
How can I solve/work around this?