Commit 727d9672 authored by Alexander's avatar Alexander

Daily release 14.03.2018

parents 54267e59 e6b36a9c
......@@ -41,6 +41,16 @@ class IOTestsWithError extends Assignment2TestBase {
testWithIOFile(getDataFolderDirectory() + "error_tests/athlete_tests.io");
}
/**
* Tests the creation of competitions and medals
*/
@Test
@DisplayName("medal-tests")
void medalTests() {
testWithIOFile(getDataFolderDirectory() + "error_tests/medal_tests.io");
}
/**
* Tests the creation of athletes
*/
......
......@@ -21,7 +21,7 @@ public class PerformanceTest extends Assignment2TestBase {
/**
* The following 2 performance tests are disabled because they wont finish in acceptable time
* unless your implementation has a good time complexity. Fell free to enable them
* by removing '@Disabled'. You may run them individually because they need a hugh
* by removing '@Disabled'. You may run them individually because they need a huge
* amount of memory.
*/
......
Tests competition with focus on medals
> add-admin Leon;Mustermann;leon;12345678
OK
> login-admin leon;12345678
OK
> add-ioc-code 001;can;canada;2000
OK
> add-ioc-code 123;ger;deutschland;1994
OK
> add-olympic-sport fencing;fencing
OK
> add-olympic-sport bobsport;bob
OK
> add-athlete 0001;max;mustermann;deutschland;bobsport;bob
OK
> add-competition 0001;2002;deutschland;fencing;fencing;1;0;0
Error, the athlete 0001, max mustermann does not compete in fencing, fencing
> add-competition 0001;2002;deutschland;bobsport;bob;1;1;0
Error, one player can only win one medal at a competition!
> add-competition 0001;2002;deutschland;bobsport;bob;1;0;0
OK
> 0001;2002;deutschland;bobsport;bob;1;1;0
Error, not a valid command!
> add-competition 0000;2002;deutschland;bobsport;bob;1;0;0
Error, An Athlete with ID 0000 does not exist.
> add-competition 0001;2018;deutschland;bobsport;bob;0;2;0
Error, one player can only win one medal at a competition!
> add-competition 0001;2002;deutschland;bobsport;bob;01;0;0
Error, not a valid command!
> add-competition 0001;2002;deutschland;bobsport;bob;1;0;2
Error, one player can only win one medal at a competition!
> add-competition 0001;2002;deutschland;bobsport;bob;1;0;0
Error, Competition already assigned to athlete
> add-competition 0001;2002;deutschland;bobsport;bob;0;1;0
Error, Competition already assigned to athlete
> add-competition 0001;2002;ger;bobsport;bob;1;0;0
Error, A country with name ger does not exist.
> add-competition 0001;2002;deutschland;bobsport;1;0;0
Error, not a valid command!
> add-competition 00001;2002;deutschland;bobsport;bob;1;0;0
Error, not a valid command!
> add-competition 0001;2022;deutschland;bobsport;bob;1;0;0
Error, Year out of range.
> add-competition 0201;2002;deutschland;bobsport;bob;1;0;0
Error, An Athlete with ID 0201 does not exist.
> add-competition 0001;2002;deutschland;bobsport;bob;1;0;0
Error, Competition already assigned to athlete
> add-athlete 0003;max;mustermann;deutschland;bobsport;bob
OK
> list-olympic-sports
bobsport bob
fencing fencing
> add-competition 0003;2018;deutschland;bobsport;bob;1;0;0
OK
> add-competition 0001;2018;deutschland;bobsport;bob;1;0;0
OK
> add-competition 0001;2018;deutschland;bobsport;bob;1;0;0
Error, Competition already assigned to athlete
> add-competition 0001;2018;deutschland;bobsport;bob;0;0;0
Error, Competition already assigned to athlete
> add-athlete 0002;alex;mustermann;deutschland;bobsport;bob
OK
> add-competition 0002;2018;deutschland;bobsport;bob;0;1;0
OK
\ No newline at end of file
......@@ -204,11 +204,11 @@ public abstract class TestBase {
for (TestPair testPair : testPairs) {
log.info("Testing " + testPair);
String output = popProgramOutput();
assert output != null || testPair.getType().equals(TestPair.Type.CHECK_FOR_NO_OUTPUT)
assert !Terminal.OUT_TEST.isEmpty()
: "got no output, this should never happen, since this is handled by the Terminal";
String output = popProgramOutput();
switch (testPair.getType()) {
case CHECK_EQUALS:
if (!testPair.getOutput().equals(output)) {
......@@ -218,19 +218,19 @@ public abstract class TestBase {
}
break;
case CHECK_STARTS_WITH:
if (!(output != null && output.startsWith(testPair.getOutput()))) {
if (output == null || !output.startsWith(testPair.getOutput())) {
log.info(" Failed!\n");
failAndLog(testPair.getFailMessage(output));
}
break;
case CHECK_CONTAINS:
if (!(output != null && output.contains(testPair.getOutput()))) {
if (output == null || !output.contains(testPair.getOutput())) {
log.info(" Failed!\n");
failAndLog(testPair.getFailMessage(output));
}
break;
case CHECK_FOR_ERROR:
if (!(output != null && output.startsWith(ERROR_PREFIX))) {
if (output == null || !output.startsWith(ERROR_PREFIX)) {
log.info(" Failed!\n");
failAndLog(testPair.getFailMessage(output));
}
......@@ -241,7 +241,6 @@ public abstract class TestBase {
printLog();
fail("Output should have been empty but was:" + output);
}
break;
case NO_CHECK:
break;
......
......@@ -2,6 +2,10 @@ package test;
public class TestPair {
public String getFailMessage(String actualOutput) {
if (actualOutput == null) {
return "Fail with " + this + "\nThe program provided no output for that command";
}
return "Fail with " + this + "\nOutput was"
+ (actualOutput.contains("\n") ? "\n" : " ")
+ actualOutput + (actualOutput.isEmpty() ? "(empty)" : "");
......@@ -68,7 +72,6 @@ public class TestPair {
@Override
public String toString() {
if (type == Type.CHECK_FOR_ERROR && output.equals(TestBase.ERROR_PREFIX + "...")
|| type == Type.CHECK_FOR_NO_OUTPUT) {
return "TestPair{'" + input + " @" + type + "}";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment