Tagged: surefire

finding the current test method


테스트 메서드 하나가 끝나지 않고 계속 도는 듯 하다. 어떤 클래스의 어떤 메서드인지 다음과 같이 리스너를 하나 만들어서 사용했다.

public class InvokedMethodListener implements IInvokedMethodListener {

    @Override
    public void beforeInvocation(final IInvokedMethod method,
                                 final ITestResult result) {
        logger.debug("beforeInvocation({}, {})", method, result);
    }

    @Override
    public void afterInvocation(final IInvokedMethod method,
                                final ITestResult result) {
        // not interested
    }
}
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <configuration>
    <properties>
      <property>
        <name>listeners</name>
        <value>package.to.the.InvokedMethodListener</value>
      </property>
    </properties>
  </configuration>
</plugin>
HH.mm.ss.SSS [main] DEBUG package.to.the.InvokedMethodListener - beforeInvocation(...)

derby properties with maven-surefire-plugin


It seems that derby log files generated on the root.

$ ls -l
...
-rw-r--r-- 1 onacit Users 13K 3월  29 18:11 pom.xml
drwxr-xr-x 1 onacit Users   0 5월  23  2012 src/

$ mvn clean test
...

$ ls -l
...
-rw-r--r-- 1 onacit Users 660 4월   1 12:28 derby.log
-rw-r--r-- 1 onacit Users 13K 3월  29 18:11 pom.xml
drwxr-xr-x 1 onacit Users   0 5월  23  2012 src/

$

Nasty, huh?

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <configuration>
    <systemProperties>
      <property>
        <name>derby.stream.error.file</name>
        <value>target/derby.log</value>
      </property>
      <property>
        <name>derby.locks.monitor</name>
        <value>true</value>
      </property>
      <property>
        <name>derby.locks.deadlockTrace</name>
        <value>true</value>
      </property>
      <property>
        <name>derby.language.logStatementText</name>
        <value>true</value>
      </property>
    </systemProperties>
  </configuration>
</plugin>
$ ls -l
...
-rw-r--r-- 1 onacit Users 13K 3월  29 18:11 pom.xml
drwxr-xr-x 1 onacit Users   0 5월  23  2012 src/

$ mvn clean test
...

$ ls -l
...
-rw-r--r-- 1 onacit Users 13K 3월  29 18:11 pom.xml
drwxr-xr-x 1 onacit Users   0 5월  23  2012 src/

$ ls -l target/
...
drwxr-xr-x 1 onacit Users   0 4월   1 12:39 classes/
-rw-r--r-- 1 onacit Users 34K 4월   1 12:40 derby.log
drwxr-xr-x 1 onacit Users   0 4월   1 12:39 generated-sources/
drwxr-xr-x 1 onacit Users   0 4월   1 12:39 generated-test-sources/
drwxr-xr-x 1 onacit Users   0 4월   1 12:40 surefire-reports/
drwxr-xr-x 1 onacit Users   0 4월   1 12:39 test-classes/

$