|
|
# Regular Unit Test
|
|
|
```java
|
|
|
@Test
|
|
|
public void shouldExecutePipelineCorrectly() throws Exception {
|
|
|
String[] inputElements = { "a", "b", "c" };
|
|
|
GlobalTaskQueueConfig<String> config = new GlobalTaskQueueConfig<>(inputElements);
|
|
|
Execution<GlobalTaskQueueConfig<String>> execution = new Execution<>(config);
|
|
|
execution.executeBlocking();
|
|
|
|
|
|
String[] expectedElements = { "a", "b", "c" };
|
|
|
assertThat(inputElements, is(equalTo(expectedElements)));
|
|
|
}
|
|
|
```
|
|
|
|
|
|
# Unit Test with our Stage Testing Framework
|
|
|
```java
|
|
|
import static org.hamcrest.collection.IsIterableContainingInOrder.contains;
|
|
|
import static org.hamcrest.core.Is.is;
|
|
|
import static org.junit.Assert.assertThat;
|
|
|
import static teetime.framework.test.StageTester.test;
|
|
|
|
|
|
public class CounterTest {
|
|
|
|
|
|
private Counter<Integer> counter;
|
|
|
|
|
|
@Before
|
|
|
public void initializeCounter() {
|
|
|
counter = new Counter<Integer>();
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
public void counterValueShouldBeCorrect() {
|
|
|
test(counter).and().send(1, 2, -5, 10, 9).to(counter.getInputPort()).start();
|
|
|
|
|
|
assertThat(counter.getNumElementsPassed(), is(5));
|
|
|
}
|
|
|
}
|
|
|
```
|
|
|
|
|
|
More example tests written with our stage testing framework can be found in the [source code](https://build.se.informatik.uni-kiel.de/teetime/teetime/tree/master/src/test/java/teetime/stage). |
|
|
\ No newline at end of file |