This plugin allow to generate test result in MarkDown
Add in your pom.xml the dependency to SequenceDiagramPlugin :
pom.xml:
<project>
...
<dependencies>
...
<dependency>
<groupId>com.github.slezier</groupId>
<artifactId>sft-md-report</artifactId>
<version>1.10</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Add Custom configuration using this plugin:
src/test/java/bancomat/CustomConfiguration.java:
...
public class CustomConfiguration extends DefaultConfiguration {
public CustomConfiguration() {
getReport().addDecorator(SequenceDiagram.class, HtmlSequenceDiagram.class);
}
}
Add decorate annotation using SequenceDiagram decorator and parameters indicating roles and arrow to displays.
i.e. @Decorate(decorator = SequenceDiagram.class,parameters = "atm -> account_holder")
will add a sequence diagram with two roles : atm and account_holder, this fixture call will add an arrow from atm to account_holder
example src/test/java/bancomat/AccountHolderWithdrawCash.java:
...
@Using(CustomConfiguration.class)
public class AccountHolderWithdrawCash {
....
@Test
public void accountHasSufficientFunds() {
bankHelper.theAccountBalanceIs(100);
bankHelper.andTheCardIsValid();
bankHelper.andTheMachineContainsEnoughMoney();
bankHelper.requestCash(20);
dispenseCash(20);
bankHelper.andTheAccountBalanceShouldBe(80);
bankHelper.cardIsReturned();
}
@Decorate(decorator = SequenceDiagram.class,parameters = "atm --> account_holder")
@Text("dispenses ${cash} $")
private void dispenseCash(int cash) {
this.ticket= bankHelper.getHtmlTicket();
assertEquals(bankHelper.withdrawals, cash);
}
...
}
src/test/java/bancomat/AccountHolderWithdrawCash.java:
...
public class BankHelper {
...
@Decorate(decorator = SequenceDiagram.class,parameters = "account_holder -> atm")
@Text("requests ${amount} $")
public void requestCash(int amount) {
atmSession = atm.authenticate(user);
withdrawals = atmSession.withdraw(amount);
}
@Decorate(decorator = SequenceDiagram.class,parameters = "atm -> atm")
@Text("account balance is ${balance} $")
public void andTheAccountBalanceShouldBe(int balance) {
assertEquals(account.balance(), balance);
}
@Decorate(decorator = SequenceDiagram.class,parameters = "atm -> account_holder")
public void cardIsReturned() {
assertTrue("Card not returned", atm.returnCard());
}
...
}