IDEMPIERE-6005 Unit Test: Display the test method to be executed in t… (#2217)

* IDEMPIERE-6005 Unit Test: Display the test method to be executed in the console

* IDEMPIERE-6005 Unit Test: Display the test method to be executed in the console

- Fix wrong configuration that run unit test twice
- added assembleRepository flag

* IDEMPIERE-6005 Unit Test: Display the test method to be executed in the console

- print classname.methodname() instead of just methodname()
This commit is contained in:
hengsin 2024-02-03 21:40:21 +08:00 committed by Carlos Ruiz
parent 087b936e2b
commit cdcf5d47f3
3 changed files with 34 additions and 16 deletions

View File

@ -11,6 +11,7 @@
<packaging>eclipse-repository</packaging>
<properties>
<materializeProduct>package</materializeProduct>
<assembleRepository>package</assembleRepository>
</properties>
<build>
<plugins>
@ -106,14 +107,14 @@
<goals>
<goal>assemble-repository</goal>
</goals>
<phase>package</phase>
<phase>${assembleRepository}</phase>
</execution>
<execution>
<id>default-archive-repository</id>
<goals>
<goal>archive-repository</goal>
</goals>
<phase>package</phase>
<phase>${assembleRepository}</phase>
</execution>
</executions>
<configuration>

View File

@ -58,6 +58,14 @@
<skipTests>${skipTests}</skipTests>
<providerHint>junit59</providerHint>
</configuration>
<executions>
<execution>
<id>default-test</id>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
@ -117,10 +125,10 @@
<versionRange>0.0.0</versionRange>
</requirement>
<requirement>
<type>eclipse-plugin</type>
<id>org.idempiere.tablepartition</id>
<versionRange>0.0.0</versionRange>
</requirement>
<type>eclipse-plugin</type>
<id>org.idempiere.tablepartition</id>
<versionRange>0.0.0</versionRange>
</requirement>
</extraRequirements>
</dependency-resolution>
</configuration>

View File

@ -28,6 +28,7 @@ import static org.junit.jupiter.api.Assertions.fail;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.Optional;
import java.util.Properties;
import org.adempiere.util.ServerContext;
@ -40,14 +41,17 @@ import org.compiere.util.Language;
import org.compiere.util.Trx;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.TestInfo;
import org.junit.jupiter.api.extension.BeforeAllCallback;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.extension.ExtensionContext;
/**
* Abstract base class for all test case
* @author hengsin
*
*/
@ExtendWith(AbstractTestCase.MyBeforeAllCallback.class)
public abstract class AbstractTestCase {
private Trx trx;
@ -59,20 +63,18 @@ public abstract class AbstractTestCase {
protected final int GARDEN_WORLD_ADMIN_ROLE = DictionaryIDs.AD_Role.GARDEN_WORLD_ADMIN.id;
protected final int GARDEN_WORLD_HQ_WAREHOUSE = DictionaryIDs.M_Warehouse.HQ.id;
@BeforeAll
/**
* setup for class
*/
static void setup() {
Adempiere.startup(false);
}
@BeforeEach
/**
* Init for each test method
* @param testInfo
*/
protected void init(TestInfo testInfo) {
StringBuilder builder = new StringBuilder("Running ");
Optional<Class<?>> optional = testInfo.getTestClass();
if (optional.isPresent())
builder.append(optional.get().getName()).append(".");
builder.append(testInfo.getDisplayName());
System.out.println(builder.toString());
ServerContext.setCurrentInstance(new Properties());
String trxName = Trx.createTrxName(getClass().getName()+"_");
@ -230,4 +232,11 @@ public abstract class AbstractTestCase {
*/
static void shutdown() {
}
private static final class MyBeforeAllCallback implements BeforeAllCallback {
@Override
public void beforeAll(ExtensionContext context) throws Exception {
Adempiere.startup(false);
}
}
}