summaryrefslogtreecommitdiff
path: root/domain
diff options
context:
space:
mode:
Diffstat (limited to 'domain')
-rw-r--r--domain/build.gradle21
-rw-r--r--domain/src/main/java/mancala/domain/Foo.java11
-rw-r--r--domain/src/test/java/mancala/domain/FooTest.java29
3 files changed, 61 insertions, 0 deletions
diff --git a/domain/build.gradle b/domain/build.gradle
new file mode 100644
index 0000000..aea31e5
--- /dev/null
+++ b/domain/build.gradle
@@ -0,0 +1,21 @@
+plugins {
+ // Tell Gradle that we are builing java as a library (non-executable piece of code intended for use by other applications).
+ id 'java'
+ id 'java-library'
+}
+
+repositories {
+ // Specify the repository mirror that we want to download our dependencies from. JCentral is configured by default when creating a new Gradle project.
+ jcenter()
+}
+
+dependencies {
+ // Download JUnit so that we can use it in our tests.
+ testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.2'
+ testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.6.2'
+}
+
+test {
+ // For running our tests, use the test runner provided by JUnit.
+ useJUnitPlatform()
+} \ No newline at end of file
diff --git a/domain/src/main/java/mancala/domain/Foo.java b/domain/src/main/java/mancala/domain/Foo.java
new file mode 100644
index 0000000..51045fe
--- /dev/null
+++ b/domain/src/main/java/mancala/domain/Foo.java
@@ -0,0 +1,11 @@
+package mancala.domain;
+
+// Make your own mancala implementation using your design.
+// You can take this stub as an example how to make a
+// class inside a package and how to test it.
+public class Foo {
+
+ public int theAnswerToLifeTheUniverseAndEverything() {
+ return 42;
+ }
+} \ No newline at end of file
diff --git a/domain/src/test/java/mancala/domain/FooTest.java b/domain/src/test/java/mancala/domain/FooTest.java
new file mode 100644
index 0000000..2861c43
--- /dev/null
+++ b/domain/src/test/java/mancala/domain/FooTest.java
@@ -0,0 +1,29 @@
+package mancala.domain;
+
+// Your test class should be in the same
+// package as the class you're testing.
+// Usually the test directory mirrors the
+// main directory 1:1. So for each class in src/main,
+// there is a class in src/test.
+
+// Import our test dependencies. We import the Test-attribute
+// and a set of assertions.
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.*;
+
+public class FooTest {
+ // Define a test starting with @Test. The test is like
+ // a small main method - you need to setup everything
+ // and you can write any arbitrary Java code in it.
+ @Test
+ public void aNormalBorlStartsWith4Stones() {
+ Foo foo = new Foo();
+ assertEquals(42, foo.theAnswerToLifeTheUniverseAndEverything());
+ }
+
+ @Test
+ public void thisTestFailsUnfortunately() {
+ Foo foo = new Foo();
+ assertEquals(3, foo.theAnswerToLifeTheUniverseAndEverything());
+ }
+} \ No newline at end of file