Reputation: 849
I am wanting to use Concordion to write tests for a simple bankAccount pgm that is offered as part of a cucumber tutorial. I am having trouble working out how to initialize objects from the concordion test spec.
I created a method in the fixture called createAccount that took an initialBalance and account number as parameters.
I call it from the test spec with ...
<b concordion:execute="createAccount(#accountNum,#initBalance)">
but when I run the test I get an error ....
java.lang.Exception: Method createAccount should have no parameters.
I know that I can just assign values to these variables from within the fixture class but think it would be a lot more useful if I could do this from the test specification.
Below is part of my test fixture with the call to createAccount
@RunWith(ConcordionRunner.class)
public class CashMachineTest {
private Account newAccount;
int initBalance = 123;
int accountNum = 1;
@Before
public void createAccount(int accountNum, int initBalance) throws Throwable{
newAccount = new Account(accountNum, initBalance);
}
public int getBalance(){
return newAccount.getBalance();
}
public void deposit(int amount){
newAccount.deposit(amount);
}
....
Any help would be much appreciated.
Upvotes: 0
Views: 307
Reputation: 287
When you want to call the initialization method from your Concordion specification, you don't need the @Before annotation. This is used by JUnit to call methods before the execution of the actual test method. But Concordion does not run a single test method, but calls the methods in your fixture class based on your instrumentation in your specification document.
Pleas, try to remove the @Before annotation and try again.
Upvotes: 2