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

View File

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

View File

@ -28,6 +28,7 @@ import static org.junit.jupiter.api.Assertions.fail;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.Optional;
import java.util.Properties; import java.util.Properties;
import org.adempiere.util.ServerContext; import org.adempiere.util.ServerContext;
@ -40,14 +41,17 @@ import org.compiere.util.Language;
import org.compiere.util.Trx; import org.compiere.util.Trx;
import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.TestInfo; 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 * @author hengsin
*
*/ */
@ExtendWith(AbstractTestCase.MyBeforeAllCallback.class)
public abstract class AbstractTestCase { public abstract class AbstractTestCase {
private Trx trx; 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_ADMIN_ROLE = DictionaryIDs.AD_Role.GARDEN_WORLD_ADMIN.id;
protected final int GARDEN_WORLD_HQ_WAREHOUSE = DictionaryIDs.M_Warehouse.HQ.id; protected final int GARDEN_WORLD_HQ_WAREHOUSE = DictionaryIDs.M_Warehouse.HQ.id;
@BeforeAll
/**
* setup for class
*/
static void setup() {
Adempiere.startup(false);
}
@BeforeEach @BeforeEach
/** /**
* Init for each test method * Init for each test method
* @param testInfo * @param testInfo
*/ */
protected void init(TestInfo 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()); ServerContext.setCurrentInstance(new Properties());
String trxName = Trx.createTrxName(getClass().getName()+"_"); String trxName = Trx.createTrxName(getClass().getName()+"_");
@ -230,4 +232,11 @@ public abstract class AbstractTestCase {
*/ */
static void shutdown() { static void shutdown() {
} }
private static final class MyBeforeAllCallback implements BeforeAllCallback {
@Override
public void beforeAll(ExtensionContext context) throws Exception {
Adempiere.startup(false);
}
}
} }