Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
WS-17-18
assignment-tests
Commits
7fd86439
Commit
7fd86439
authored
Mar 17, 2018
by
Alexander
Browse files
Daily Release 17.03.2018
parents
727d9672
c832cc04
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/edu/kit/informatik/Terminal.java
View file @
7fd86439
...
@@ -26,6 +26,13 @@ public final class Terminal {
...
@@ -26,6 +26,13 @@ public final class Terminal {
public
static
boolean
useMyErrorMessagesInTestCreation
=
true
;
public
static
boolean
useMyErrorMessagesInTestCreation
=
true
;
private
static
StringBuilder
testPairFile
=
new
StringBuilder
();
private
static
StringBuilder
testPairFile
=
new
StringBuilder
();
/**
* Progressbar stuff
*/
private
static
boolean
showTestProgress
=
false
;
private
static
int
inputCount
=
1
;
private
static
int
numInput
=
0
;
private
static
long
time
=
0
;
/**
/**
* This field represents the input from a test to a tested program
* This field represents the input from a test to a tested program
*/
*/
...
@@ -148,6 +155,18 @@ public final class Terminal {
...
@@ -148,6 +155,18 @@ public final class Terminal {
throw
new
RuntimeException
(
e
);
throw
new
RuntimeException
(
e
);
}
}
else
{
else
{
if
(
showTestProgress
)
{
numInput
++;
if
(
numInput
%
(
inputCount
/
100
)
==
0
)
{
long
t
=
System
.
nanoTime
();
System
.
out
.
printf
(
"%03d%% +%.2f ms%n"
,
Math
.
round
((
double
)
numInput
/
inputCount
*
100.0
)
,
(
t
-
time
)
/
1000000.0
);
time
=
t
;
if
(
numInput
==
inputCount
)
{
System
.
out
.
println
();
}
}
}
//If the program outputted nothing we still have null which means "no output"
//If the program outputted nothing we still have null which means "no output"
OUT_TEST
.
add
(
null
);
OUT_TEST
.
add
(
null
);
...
@@ -239,4 +258,11 @@ public final class Terminal {
...
@@ -239,4 +258,11 @@ public final class Terminal {
useMyErrorMessagesInTestCreation
=
!
doNotUseMyErrorMessages
;
useMyErrorMessagesInTestCreation
=
!
doNotUseMyErrorMessages
;
startTestCreation
(
args
);
startTestCreation
(
args
);
}
}
public
static
void
setupShowProgress
(
boolean
showTestProgress
,
int
inputCount
)
{
Terminal
.
showTestProgress
=
showTestProgress
;
Terminal
.
inputCount
=
inputCount
;
Terminal
.
numInput
=
0
;
time
=
System
.
nanoTime
();
}
}
}
src/final_assignment/task_2/tests/PerformanceTest.java
View file @
7fd86439
...
@@ -29,6 +29,7 @@ public class PerformanceTest extends Assignment2TestBase {
...
@@ -29,6 +29,7 @@ public class PerformanceTest extends Assignment2TestBase {
@Test
@Test
@DisplayName
(
"PerformanceTest2"
)
@DisplayName
(
"PerformanceTest2"
)
void
performanceTest2
()
{
void
performanceTest2
()
{
enableShowTestProgress
();
String
path
=
getDataFolderDirectory
()
+
"performance/performance_test_2.io"
;
String
path
=
getDataFolderDirectory
()
+
"performance/performance_test_2.io"
;
TestPair
[]
pairs
=
loadTestPairsFromIOFile
(
path
);
TestPair
[]
pairs
=
loadTestPairsFromIOFile
(
path
);
enablePerformanceTest
();
enablePerformanceTest
();
...
@@ -39,6 +40,7 @@ public class PerformanceTest extends Assignment2TestBase {
...
@@ -39,6 +40,7 @@ public class PerformanceTest extends Assignment2TestBase {
@Test
@Test
@DisplayName
(
"PerformanceTest3"
)
@DisplayName
(
"PerformanceTest3"
)
void
performanceTest3
()
{
void
performanceTest3
()
{
enableShowTestProgress
();
String
path
=
getDataFolderDirectory
()
+
"performance/performance_test_3.io"
;
String
path
=
getDataFolderDirectory
()
+
"performance/performance_test_3.io"
;
TestPair
[]
pairs
=
loadTestPairsFromIOFile
(
path
);
TestPair
[]
pairs
=
loadTestPairsFromIOFile
(
path
);
enablePerformanceTest
();
enablePerformanceTest
();
...
...
src/test/TestBase.java
View file @
7fd86439
...
@@ -38,6 +38,7 @@ public abstract class TestBase {
...
@@ -38,6 +38,7 @@ public abstract class TestBase {
private
String
testName
;
private
String
testName
;
private
boolean
alwaysShowLog
;
private
boolean
alwaysShowLog
;
private
boolean
showAllProgramOutput
=
false
;
private
boolean
showAllProgramOutput
=
false
;
private
boolean
showTestProgress
;
/**
/**
* Initializes testing
* Initializes testing
...
@@ -57,6 +58,7 @@ public abstract class TestBase {
...
@@ -57,6 +58,7 @@ public abstract class TestBase {
protected
void
initTest
(
TestInfo
testInfo
)
{
protected
void
initTest
(
TestInfo
testInfo
)
{
alwaysShowLog
=
false
;
alwaysShowLog
=
false
;
testPassed
=
false
;
testPassed
=
false
;
showTestProgress
=
false
;
testName
=
testInfo
.
getDisplayName
();
testName
=
testInfo
.
getDisplayName
();
log
=
Logger
.
getLogger
(
testInfo
.
getClass
().
getName
());
log
=
Logger
.
getLogger
(
testInfo
.
getClass
().
getName
());
log
.
setUseParentHandlers
(
false
);
log
.
setUseParentHandlers
(
false
);
...
@@ -199,6 +201,7 @@ public abstract class TestBase {
...
@@ -199,6 +201,7 @@ public abstract class TestBase {
}
}
pushProgramInput
(
"quit"
);
pushProgramInput
(
"quit"
);
Terminal
.
setupShowProgress
(
showTestProgress
,
Terminal
.
IN_TEST
.
size
());
testedMethod
.
run
();
testedMethod
.
run
();
for
(
TestPair
testPair
:
testPairs
)
{
for
(
TestPair
testPair
:
testPairs
)
{
...
@@ -206,7 +209,7 @@ public abstract class TestBase {
...
@@ -206,7 +209,7 @@ public abstract class TestBase {
assert
!
Terminal
.
OUT_TEST
.
isEmpty
()
assert
!
Terminal
.
OUT_TEST
.
isEmpty
()
:
"got no output, this should never happen, since this is handled by the Terminal"
;
:
"got no output, this should never happen, since this is handled by the Terminal"
;
String
output
=
popProgramOutput
();
String
output
=
popProgramOutput
();
switch
(
testPair
.
getType
())
{
switch
(
testPair
.
getType
())
{
...
@@ -366,4 +369,11 @@ public abstract class TestBase {
...
@@ -366,4 +369,11 @@ public abstract class TestBase {
protected
void
enableShowAllProgramOutput
()
{
protected
void
enableShowAllProgramOutput
()
{
this
.
showAllProgramOutput
=
true
;
this
.
showAllProgramOutput
=
true
;
}
}
/**
* Shows a progress-bar for this test
*/
protected
void
enableShowTestProgress
()
{
showTestProgress
=
true
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment