DEPRECATED - please use lsd-core instead
Ubuntu | OSX |
---|---|
Maven Central | Jitpack |
---|---|
This project builds upon (and breaks away from) the excellent original Yatspec project.
It focuses heavily on the Sequence Diagram capabilities of the framework for turning tests into Living Sequence Diagrams
.
- Java 11+
- Junit 5
// Any one of these repositories
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
...
}
dependencies {
testImplementation 'com.github.nickmcdowall:yatspec:<latest-release>'
...
}
Create a new JUnit5 Test:
@ExtendWith(SequenceDiagramExtension.class)
public class SequenceDiagramExampleTest {
// Use this instance to log interactions by calling the log() method
private TestState interactions = new TestState();
@Test
public void messageFromUpstreamToDownstream() {
// (these method names are `wordified` and turned into the specification description)
givenSomeSetup();
whenSomeActionOccurs();
thenXHappens();
}
private void givenSomeSetup() {
// setup your scenario
}
private void whenSomeActionOccurs() {
// trigger action and capture interactions e.g.
interactions.log("message from A to B", "hi!");
}
private void thenXHappens() {
// assertions
}
}
HTML reports will be generated under <build_dir>/reports/yatspec
For an example project using yatspec see yatspec-example.
- To specify the output directory for generated reports set a system property called
yatspec.output.dir
- To shorten the text displayed on the arrows of the sequence diagrams you can set the system property
yatspec.sequence.text.abbreviate.length
to a numeric value that specifies the maximum character length. - To include a Component Diagram in below each sequence diagram you need to set the system property
"yatspec.diagram.component.enabled"
to"true"
.
** Note that this requiresGraphviz
to be installed on the machine running the tests (e.g. brew install graphviz - see https://graphviz.org/download/) and is still in an experimental phase.
If you are writing SpringBootTests then you can make use of the yatspec-lsd-interceptors library which provides interceptors for http calls and can also auto configure certain beans to minimise the boilerplate code necessary wire everything together.
I'd like to use a particular commit version that hasn't been released.
Not a problem! (no guarantees it works either!)
Add the Jitpack maven repo to your build.gradle file and update the version to be the commit sha:
repositories {
...
maven { url 'https://jitpack.io' }
...
}
...
dependencies {
testImplementation 'com.github.nickmcdowall:yatspec:<commit-sha>'
...
}
FYI Jitpack can be used as an alternative to mavenCentral() for latest releases too:
Help my report output contains an error message instead of pretty sequence diagram
This often occurs if you use a source or destination name that contains a character that PlantUML doesn't like
so try to keep the names simple and avoid special characters including hyphens '-
'.