Skip to content

Commit 4e4dbed

Browse files
committed
Changed the output layout for the IT's
1 parent a52e9a2 commit 4e4dbed

1 file changed

Lines changed: 27 additions & 34 deletions

File tree

jenkins-client-it-docker/src/test/java/com/offbytwo/jenkins/integration/MethodListener.java

Lines changed: 27 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,59 +6,52 @@
66
import org.testng.ITestResult;
77
import org.testng.SkipException;
88

9-
public class MethodListener
10-
implements IInvokedMethodListener
11-
{
12-
9+
public class MethodListener implements IInvokedMethodListener {
10+
1311
private String lastClassWithoutPackage;
1412

15-
private String getClassNameWithoutPackage( String canonicalName )
16-
{
17-
int lastIndexOf = canonicalName.lastIndexOf( '.' );
18-
return canonicalName.substring( lastIndexOf + 1 );
13+
private String getClassNameWithoutPackage(String canonicalName) {
14+
int lastIndexOf = canonicalName.lastIndexOf('.');
15+
return canonicalName.substring(lastIndexOf + 1);
1916
}
2017

2118
@Override
22-
public void beforeInvocation( IInvokedMethod method, ITestResult testResult )
23-
{
24-
if ( method.isTestMethod() )
25-
{
19+
public void beforeInvocation(IInvokedMethod method, ITestResult testResult) {
20+
if (method.isTestMethod()) {
2621
ITestNGMethod testMethod = method.getTestMethod();
27-
String classNameWithoutPackage = getClassNameWithoutPackage( testMethod.getTestClass().getName() );
28-
22+
String classNameWithoutPackage = getClassNameWithoutPackage(testMethod.getTestClass().getName());
23+
2924
if (lastClassWithoutPackage == null) {
30-
System.out.println( classNameWithoutPackage + ":" );
31-
System.out.print( " " + testMethod.getMethodName() + "..." );
25+
System.out.println(classNameWithoutPackage + ":");
3226
} else {
33-
if (lastClassWithoutPackage.equals( classNameWithoutPackage )) {
34-
System.out.print( " " + testMethod.getMethodName() + "..." );
35-
} else {
36-
System.out.println( classNameWithoutPackage + ":" );
37-
System.out.print( " " + testMethod.getMethodName() + "..." );
27+
if (!lastClassWithoutPackage.equals(classNameWithoutPackage)) {
28+
System.out.println(classNameWithoutPackage + ":");
3829
}
3930
}
4031
lastClassWithoutPackage = classNameWithoutPackage;
4132
}
4233
}
4334

4435
@Override
45-
public void afterInvocation( IInvokedMethod method, ITestResult testResult )
46-
{
47-
if ( method.isTestMethod() )
48-
{
49-
if ( testResult.isSuccess() )
50-
{
51-
System.out.println( "Done." );
52-
}
53-
else
54-
{
55-
//Isn't there an more elegant way?
36+
public void afterInvocation(IInvokedMethod method, ITestResult testResult) {
37+
if (method.isTestMethod()) {
38+
ITestNGMethod testMethod = method.getTestMethod();
39+
String classNameWithoutPackage = getClassNameWithoutPackage(testMethod.getTestClass().getName());
40+
41+
if (testResult.isSuccess()) {
42+
System.out.print(" SUCCESS ");
43+
} else {
44+
// Isn't there an more elegant way?
5645
if (testResult.getThrowable() instanceof SkipException) {
57-
System.out.println( "SKIPPED. ( " + testResult.getThrowable().getMessage() + " )" );
46+
System.out.print(" SKIPPED ( " + testResult.getThrowable().getMessage() + " ) ");
5847
} else {
59-
System.out.println( "FAILURE." );
48+
System.out.print(" FAILURE ");
6049
}
6150
}
51+
52+
System.out.println(" " + testMethod.getMethodName());
53+
lastClassWithoutPackage = classNameWithoutPackage;
54+
6255
}
6356
}
6457

0 commit comments

Comments
 (0)