@ -44,20 +44,45 @@ public class TestUnit<T extends TestContextInterface> implements Runnable {
add ( TestSuite . getDefault ( ) ) ;
add ( TestSuite . getDefault ( ) ) ;
}
}
//Shallow Copy
public TestUnit ( TestUnit < T > orig ) {
testUnitName = orig . testUnitName ;
ctx = orig . ctx ;
lambda = orig . lambda ;
result = orig . result ;
state = orig . state ;
lastException = orig . lastException ;
verboseMode = orig . verboseMode ;
testColor = orig . testColor ;
logFmtPadding = orig . logFmtPadding ;
logFmtMsgLen = orig . logFmtMsgLen ;
logFmtTestDuration = orig . logFmtTestDuration ;
lineWidthMin = orig . lineWidthMin ;
logFmtTestNameLen = orig . logFmtTestNameLen ;
logFmtCtxNameLen = orig . logFmtCtxNameLen ;
}
//Shallow Copy
public TestUnit < T > copy ( ) {
return new TestUnit < > ( this ) ;
}
public boolean isVerboseMode ( ) {
public boolean isVerboseMode ( ) {
return verboseMode ;
return verboseMode ;
}
}
public void setVerboseMode ( boolean verboseMode ) {
public TestUnit < T > setVerboseMode ( boolean verboseMode ) {
this . verboseMode = verboseMode ;
this . verboseMode = verboseMode ;
return this ;
}
}
public TermColor getTestColor ( ) {
public TermColor getTestColor ( ) {
return testColor ;
return testColor ;
}
}
public void setTestColor ( TermColor testColor ) {
public TestUnit < T > setTestColor ( TermColor testColor ) {
this . testColor = testColor ;
this . testColor = testColor ;
return this ;
}
}
public TestState getResult ( ) {
public TestState getResult ( ) {
@ -82,6 +107,11 @@ public class TestUnit<T extends TestContextInterface> implements Runnable {
return ctx ;
return ctx ;
}
}
public TestUnit < T > setContext ( T ctx ) {
this . ctx = ctx ;
return this ;
}
public void run ( ) {
public void run ( ) {
TestUtils . standardOutErrEnabled ( verboseMode ) ;
TestUtils . standardOutErrEnabled ( verboseMode ) ;
if ( ctx . isUninitializable ( ) ) {
if ( ctx . isUninitializable ( ) ) {
@ -154,7 +184,7 @@ public class TestUnit<T extends TestContextInterface> implements Runnable {
}
}
private void setTestResult ( TestState r ) {
private void setTestResult ( TestState r ) {
assert ( r = = TestState . SKIPPED | | r = = TestState . FAILED | | r = = TestState . SUCCESS | | r = = TestState . UNEVALUATED ) : "PityTest Internal: illegal result value '" + r + "'" ;
assert ( r = = TestState . SKIPPED | | r = = TestState . FAILED | | r = = TestState . SUCCESS | | r = = TestState . UNEVALUATED ) : "PityTest Internal: illegal result value '" + r + "'" ;
result = r ;
result = r ;
TestUtils . standardOutErrEnabled ( true ) ;
TestUtils . standardOutErrEnabled ( true ) ;
logH1 ( makeLogString ( ) ) ;
logH1 ( makeLogString ( ) ) ;
@ -193,7 +223,7 @@ public class TestUnit<T extends TestContextInterface> implements Runnable {
DecimalFormat f = new DecimalFormat ( "0.000" ) ;
DecimalFormat f = new DecimalFormat ( "0.000" ) ;
String durationFmtd = f . format ( testDuration . toMillis ( ) / 1000 . 0 ) ;
String durationFmtd = f . format ( testDuration . toMillis ( ) / 1000 . 0 ) ;
strTestDuration = TestUtils . padOrClipString ( " [" + durationFmtd + " sec] " , "=" , logFmtTestDuration , TestUtils . Alignment . Right , ".. " ) ;
strTestDuration = TestUtils . padOrClipString ( " [" + durationFmtd + " sec] " , "=" , logFmtTestDuration , TestUtils . Alignment . Right , ".. " ) ;
} else {
} else {
strTestDuration = TestUtils . padOrClipString ( "" , "=" , logFmtTestDuration , TestUtils . Alignment . Right , ".. " ) ;
strTestDuration = TestUtils . padOrClipString ( "" , "=" , logFmtTestDuration , TestUtils . Alignment . Right , ".. " ) ;
}
}