From 5ee1f3fe9c4b15dfa4318cccde029bcc6987f773 Mon Sep 17 00:00:00 2001 From: Stefan Suhren Date: Fri, 28 Oct 2016 11:32:46 +0200 Subject: Add tests for the Dreieck class --- build.gradle | 13 +++++++++++++ test/DreieckTest.java | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 test/DreieckTest.java diff --git a/build.gradle b/build.gradle index df121c2..6a26d05 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,10 @@ apply plugin: 'java' apply plugin: 'application' +repositories { + mavenCentral() +} + defaultTasks 'clean', 'build' task init << { @@ -19,12 +23,21 @@ run { standardInput = System.in; } +dependencies { + testCompile 'junit:junit:4.12' +} + sourceSets { main { //if you truly want to override the defaults: java.srcDirs = ['src'] output.classesDir = 'classes' } + test { + java { + srcDirs = ["test"] + } + } } javadoc { diff --git a/test/DreieckTest.java b/test/DreieckTest.java new file mode 100644 index 0000000..ef89d77 --- /dev/null +++ b/test/DreieckTest.java @@ -0,0 +1,50 @@ +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +public class DreieckTest +{ + // Dreieck myD = new Dreieck(); + + @Test + public void testNicht() + { + String retValue = Dreieck.getType(3, 4, 10); + assertEquals("Kein Dreieck", retValue); + } + + @Test + public void testRechtw() + { + String retValue = Dreieck.getType(3, 4, 5); + assertEquals("Rechtwinkliges Dreieck", retValue); + } + + @Test + public void testGleichseit() + { + String retValue = Dreieck.getType(4, 4, 4); + assertEquals("Gleichseitiges Dreieck", retValue); + } + + @Test + public void testGleichsch() + { + String retValue = Dreieck.getType(4, 4, 10); + assertEquals("Gleichschenkliges Dreieck", retValue); + } + + @Test + public void testBel() + { + String retValue = Dreieck.getType(3, 4, 6); + assertEquals("Beliebiges Dreieck", retValue); + } + + @Test + public void testNull() + { + String retValue = Dreieck.getType(0, 4, 6); + assertEquals("Kein Dreieck", retValue); + } +} -- cgit v1.2.3-70-g09d2