Skip to content

Latest commit

 

History

History
50 lines (37 loc) · 1.22 KB

ManageTestContext.md

File metadata and controls

50 lines (37 loc) · 1.22 KB

Manage test context

Use JUnit annotation @Before, @After and @BeforeClass, @AfterClass to manage test context before and after each scenario, before and after all scenarios.

Manage context

Show scenario context: add @Displayable on private or protected field to displayed it.

...
public class AccountHolderWithdrawCash {
    ...
    private Object ticket = null;
    ...

Display context

Back

### Share fixtures

All public fixtures from an class annotated by @FixtureHelper can be used as local fixture.

Create public fixtures in a fixture helper:

...
public class BankHelper {
	...
    @Text("Given the account balance is ${initialAmount} $")
    public void givenTheAccountBalanceIs(int initialAmount) {
        ...
    }
	...
}

Reference the FixtureHelper and call its fixture:

...
public class AccountHolderWithdrawCash {
	@FixturesHelper
    private BankHelper bankHelper = new BankHelper();
	...
	@Test
	public void accountHasSufficientFunds() {
    	bankHelper.givenTheAccountBalanceIs(100);
    	...
    }
    ...
}

Back