The command line arguments are used to insert a permutation (or
context)
in which the test, or series of test-cases are supposed to run. For
example, the same
test can be run with or without transactions - but the test logic
remains as is.
So I would have something like:
public class TestNg
{
public TestNg(String[] args)
{
//parse arguments and save
//in the context of the TestNg instance.
}
}
can someone guide me through?
Thank you.
my understanding is that the test(boolean useTransactions) would be run
once with true and the other with false automatically. Meaning I won't
have to add delegating methods...
Well, I went out and tried this as follows:
@DataProvider(name = "transaction")
public Object[][] createTransactionSettings() {
return new Object[][] {
new Object[] { TxnSupport.LOCAL_TXN },
new Object[] { TxnSupport.JINI_TXN },
};
}
@Parameters({ "transaction" })
@Test
public TestNg(TxnSupport transaction)
{
transactionType = transaction;
}
But, immediately got the following:
org.testng.TestNGException:
Parameter 'transaction' is required by @Parameters on method public
com.framework.TestNg(com.framework.TestNg$TxnSupport)
but has not been defined in D:\cvs\QA\temp-testng-customsuite.xml
at
org.testng.internal.Parameters.createParameters(Parameters.java:102)
at org.testng.internal.Parameters.createParameters(Parameters.java:37)
I looked at the customsuite file it created, and it doesn't contain any
parameters -
but should it? My intention is that it would run it twice with both
parameters.
I can live with the 'permutations' being inside the test and not passed
as arguments,
but this then would have to work as I assume - running each method as
many times
as it's data provider feeds it.
Thank you.
Thank you for the prompt response.
my understanding is that the test(boolean useTransactions) would be run
once with true and the other with false automatically. Meaning I won't
have to add delegating methods...
Well, I went out and tried this as follows:
@DataProvider(name = "transaction")
public Object[][] createTransactionSettings() {
return new Object[][] {
new Object[] { TxnSupport.LOCAL_TXN },
new Object[] { TxnSupport.JINI_TXN },
};
}
@Parameters({ "transaction" })
@Test
public TestNg(TxnSupport transaction)
{
transactionType = transaction;
}
But, immediately got the following: