Skip to content

A JUnit extension to easily adopt functional testing and acceptance testing

License

Notifications You must be signed in to change notification settings

slezier/SimpleFunctionalTest

Repository files navigation

# SimpleFunctionalTest

A JUnit extension to easily adopt functional testing and acceptance testing

step 1: make your test readable

In JUnit test: refactor your test in order to make it more readable by non java native speaker.

  • Add comment before class or test method
  • Use expressive names (camelCase or underscore) for your class, test methods and other methods
  • In your test ONLY use method calls

A 'more' readable JUnit test for a non native java speaker:

...
/*
As an Account Holder
I want to withdraw cash from an ATM
So that I can get money when the bank is closed
*/
public class AccountHolderWithdrawCash {
	...
	@Test
	public void accountHasSufficientFunds() {
		givenTheAccountBalanceIs100Dollars();
		andTheCardIsValid();
		andTheMachineContainsEnoughMoney();

		whenTheAccountHolderRequests20Dollars();

		thenTheAtmShouldDispense20Dollars();
		andTheAccountBalanceShouldBe80Dollars();
		andTheCardShouldBeReturned();
	}

	private void givenTheAccountBalanceIs100Dollars(){
	    ...
	}
    ...
}

step 2: add SimpleFunctionalTest

In your pom file: insert dependencies to SimpleFunctionalTest

<project>
	...
	<dependencies>
		...
		<dependency>
			<groupId>com.github.slezier</groupId>
			<artifactId>SimpleFunctionalTest</artifactId>
			<version>1.8</version>
			<scope>test</scope>
		</dependency>
	</dependencies>
</project>

and specify SimpleFunctionalTest as JUnit runner:

...
@RunWith(SimpleFunctionalTest.class)
public class AccountHolderWithdrawCash {
	...

step 3: enjoy

Run the test.

Open the html file generated:

A simple acceptance test using SFT

Other fixtures

Use weirds characters or specify the way is displayed.

Parameterize your fixture.

Links use cases together.

Manage test context.

Decorate: Table of content, breadcrumb, group fixtures, fixture displayed as table.

Deeper

How to use SimpleFunctionalTest

See also

Available release:

  • 1.9: New usecase decorator: Synthesis jar doc
  • 1.8: Can add new decorator, context is displayed even if failure occurs jar doc
  • 1.7: Better ide integration, Fix configuration uses, add Group decorator for scenarios jar doc
  • 1.6: Table decorator, @Displayable @Before @After @BeforeClass @AfterClass from FixturesHelper, preserve empty line in scenario jar doc
  • 1.5: Bug fix jar doc
  • 1.4: Bug fix jar doc
  • 1.3: Decorators and setting jar doc
  • 1.2: Using test context jar doc
  • 1.1: Basic testing: UseCase Scenario Fixture SubUseCase and FixtureHelper jar doc

About

A JUnit extension to easily adopt functional testing and acceptance testing

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •