Page History
...
In this scenario, we want to get visibility of the automated test results from some tests implemented in Java, using the JUnit framework.
This recipe could also be applied for other frameworks such as NUnit or Robot.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
package com.xpand.java; import org.junit.After; import org.junit.Before; import org.junit.Test; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; public class CalcTest { @Before public void setUp() throws Exception { } @After public void tearDown() throws Exception { } @Test public void CanAddNumbers() { assertThat(Calculator.Add(1, 1), is(2)); assertThat(Calculator.Add(-1, 1), is(0)); } @Test public void CanSubtract() { assertThat(Calculator.Subtract(1, 1), is(0)); assertThat(Calculator.Subtract(-1, -1), is(0)); assertThat(Calculator.Subtract(100, 5), is(95)); } @Test public void CanMultiply() { assertThat(Calculator.Multiply(1, 1), is(1)); assertThat(Calculator.Multiply(-1, -1), is(1)); assertThat(Calculator.Multiply(100, 5), is(500)); } public void CanDivide() { assertThat(Calculator.Divide(1, 1), is(1)); assertThat(Calculator.Divide(-1, -1), is(1)); assertThat(Calculator.Divide(100, 5), is(20)); } @Test public void CanDoStuff() { assertThat(true, is(true)); } } |
...