Skip to content

Commit

Permalink
Upgrading testng and surefire
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Aug 15, 2014
1 parent 1f36c63 commit 556775f
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 12 deletions.
12 changes: 9 additions & 3 deletions build-system/pom.xml
Expand Up @@ -59,7 +59,7 @@
<slf4j.version>1.6.4</slf4j.version>
<spring.version>3.1.0.RELEASE</spring.version>
<spring.security.version>3.1.0.RELEASE</spring.security.version>
<testng.version>6.1.1</testng.version>
<testng.version>6.8.8</testng.version>
<xml.resolver.version>1.2</xml.resolver.version>
<cron4j.version>2.2.3</cron4j.version>
<hibernate.version>4.1.12.Final</hibernate.version>
Expand Down Expand Up @@ -736,7 +736,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.10</version>
<version>2.17</version>
<configuration>
<forkMode>once</forkMode>
<!-- <runOrder>alphabetical</runOrder> -->
Expand All @@ -748,6 +748,12 @@
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
<properties>
<property>
<name>listener</name>
<value>com.evolveum.midpoint.tools.testng.TestMethodLoggerListener</value>
</property>
</properties>
<systemPropertyVariables>
<midpoint.home>target/midpoint-home</midpoint.home>
<java.util.logging.config.file>${project.build.directory}/test-classes/logging.properties</java.util.logging.config.file>
Expand All @@ -767,7 +773,7 @@
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-testng</artifactId>
<version>2.9</version>
<version>2.17</version>
</dependency>
</dependencies>
</plugin>
Expand Down
3 changes: 0 additions & 3 deletions model/model-impl/testng.xml
Expand Up @@ -16,9 +16,6 @@
-->
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="unit" parallel="false">
<listeners>
<listener class-name="com.evolveum.midpoint.tools.testng.TestMethodLoggerListener"/>
</listeners>
<test name="Model Basic" preserve-order="true" parallel="false" verbose="10" enabled="false">
<classes>
<class name="com.evolveum.midpoint.model.impl.SpringApplicationContextTest"/>
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2013 Evolveum
* Copyright (c) 2010-2014 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,6 +16,11 @@

package com.evolveum.midpoint.tools.testng;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.testng.IConfigurationListener;
import org.testng.IInvokedMethod;
import org.testng.IInvokedMethodListener;
import org.testng.ITestResult;
Expand All @@ -27,16 +32,34 @@
* Time: 16:13
* To change this template use File | Settings | File Templates.
*/
public class TestMethodLoggerListener implements IInvokedMethodListener {
public class TestMethodLoggerListener implements IInvokedMethodListener, IConfigurationListener {

private static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");

@Override
public void beforeInvocation(IInvokedMethod method, ITestResult testResult) {
System.out.println("-----------------------------------------------------------");
System.out.println("TestNG running method: " + method.getTestMethod().toString());
System.out.println(DATE_FORMAT.format(new Date()));
System.out.println("----[ TestNG running method: " + method.getTestMethod().toString() + " ("+testResult+") ]----");
}

@Override
public void afterInvocation(IInvokedMethod method, ITestResult testResult) {
System.out.println("TestNG finish method : " + method.getTestMethod().toString() + " Result: " + (testResult.isSuccess() ? "PASS" : "FAIL"));
System.out.println("-----------------------------------------------------------");
System.out.println(DATE_FORMAT.format(new Date()));
System.out.println("----[ TestNG finished method : " + method.getTestMethod().toString() + " Result: " + (testResult.isSuccess() ? "PASS" : "FAIL")+" ]----");
}

@Override
public void onConfigurationFailure(ITestResult res) {
System.out.println("--- TestNG configuration failure : " + res.getTestName());
}

@Override
public void onConfigurationSkip(ITestResult res) {
System.out.println("--- TestNG configuration skip : " + res.getTestName());
}

@Override
public void onConfigurationSuccess(ITestResult res) {
System.out.println("--- TestNG configuration success : " + res.getTestName());
}
}

0 comments on commit 556775f

Please sign in to comment.