From 9f9a3f68d4a6cebe7e33f7ad7cda4b2a7a6ccbdc Mon Sep 17 00:00:00 2001 From: Hammy Date: Thu, 5 Nov 2020 22:30:32 +0000 Subject: [PATCH] Add Hello World Project With TDD Frameworks --- .../src/main/java/hello/world/App.java | 13 ++++++++++ .../src/main/java/hello/world/Greeting.java | 17 +++++++++++++ .../src/main/java/hello/world/HelloWorld.java | 12 +++++++++ .../test/java/hello/world/HelloWorldTest.java | 25 +++++++++++++++++++ 4 files changed, 67 insertions(+) create mode 100644 Personal/Test Driven Development/Hello World/src/main/java/hello/world/App.java create mode 100644 Personal/Test Driven Development/Hello World/src/main/java/hello/world/Greeting.java create mode 100644 Personal/Test Driven Development/Hello World/src/main/java/hello/world/HelloWorld.java create mode 100644 Personal/Test Driven Development/Hello World/src/test/java/hello/world/HelloWorldTest.java diff --git a/Personal/Test Driven Development/Hello World/src/main/java/hello/world/App.java b/Personal/Test Driven Development/Hello World/src/main/java/hello/world/App.java new file mode 100644 index 0000000..6486350 --- /dev/null +++ b/Personal/Test Driven Development/Hello World/src/main/java/hello/world/App.java @@ -0,0 +1,13 @@ +package hello.world; + +/** + * Hello world! + * + */ +public class App +{ + public static void main( String[] args ) + { + System.out.println("Hello World!"); + } +} diff --git a/Personal/Test Driven Development/Hello World/src/main/java/hello/world/Greeting.java b/Personal/Test Driven Development/Hello World/src/main/java/hello/world/Greeting.java new file mode 100644 index 0000000..7143720 --- /dev/null +++ b/Personal/Test Driven Development/Hello World/src/main/java/hello/world/Greeting.java @@ -0,0 +1,17 @@ +package hello.world; + +public class Greeting { + String message; + + public Greeting() { + + } + + public Greeting(String message) { + this.message = message; + } + + public String getMessage() { return message; } + public void setMessage(String message) { this.message = message; } + +} diff --git a/Personal/Test Driven Development/Hello World/src/main/java/hello/world/HelloWorld.java b/Personal/Test Driven Development/Hello World/src/main/java/hello/world/HelloWorld.java new file mode 100644 index 0000000..9f638fc --- /dev/null +++ b/Personal/Test Driven Development/Hello World/src/main/java/hello/world/HelloWorld.java @@ -0,0 +1,12 @@ +package hello.world; + +/** + * Hello world! + * + */ +public class HelloWorld { + public static void main(String[] args) { + Greeting greeting = new Greeting("Hello World"); + System.out.println(greeting.getMessage()); + } +} diff --git a/Personal/Test Driven Development/Hello World/src/test/java/hello/world/HelloWorldTest.java b/Personal/Test Driven Development/Hello World/src/test/java/hello/world/HelloWorldTest.java new file mode 100644 index 0000000..a5a64f3 --- /dev/null +++ b/Personal/Test Driven Development/Hello World/src/test/java/hello/world/HelloWorldTest.java @@ -0,0 +1,25 @@ +package hello.world; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +/** + * Unit test for simple App. + */ +public class HelloWorldTest { + /** + * Rigorous Test :-) + */ + @Test + public void greetingMessageShouldPass() { + Greeting greeting = new Greeting("Hello World"); + assertEquals("Hello World", greeting.getMessage()); + } + + @Test + public void greetingMessageShouldFail() { + Greeting greeting = new Greeting("Not Hello World"); + assertEquals("Hello World", greeting.getMessage()); + } +}