Closed ctubbsii closed 9 months ago
One nice thing about this structure is that it makes it possible to test the example and ensure changes to the library do not break the example and visa versa. Experimented with this locally and came up with the following.
package example;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.util.List;
public class AccessExampleTest {
@Test
public void testExampleCode(){
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final PrintStream out = new PrintStream(baos);
System.setOut(out);
AccessExample.main(new String[]{"RED", "BLUE"});
var output = baos.toString();
for(var expected : List.of("data3","data5","data6","data9")) {
Assertions.assertTrue(output.contains(expected));
}
for(var unexpected : List.of("data1","data4","data7","data8")) {
Assertions.assertFalse(output.contains(unexpected));
}
}
}
I added in your test, @keith-turner , as well as a few other tweaks to the POM that were missing.