Skip to content

Commit

Permalink
SDK-357 - Follow maven recommended best practices for unit and integr…
Browse files Browse the repository at this point in the history
…ation tests (#309)
  • Loading branch information
mseaton authored Nov 18, 2024
1 parent 105f3eb commit a3cabd9
Show file tree
Hide file tree
Showing 15 changed files with 44 additions and 29 deletions.
24 changes: 24 additions & 0 deletions integration-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,28 @@
<artifactId>semver4j</artifactId>
</dependency>
</dependencies>

<profiles>
<profile>
<id>integration-tests</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.1.2</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.openmrs.maven.plugins;

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.maven.it.VerificationException;
import org.apache.maven.it.Verifier;
Expand Down Expand Up @@ -48,7 +47,7 @@


@RunWith(BlockJUnit4ClassRunner.class)
public abstract class AbstractSdkIntegrationTest {
public abstract class AbstractSdkIT {

/**
* contains name of directory in project's target dir, where integration tests are conducted
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
import org.openmrs.maven.plugins.model.DistroProperties;
import org.openmrs.maven.plugins.utility.DistroHelper;

import java.io.File;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

public class AddDependencyTest extends AbstractSdkIntegrationTest {
public class AddDependencyIT extends AbstractSdkIT {

@Test
public void shouldAddOmodDependency() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

public class AddExclusionIntegrationTest extends AbstractSdkIntegrationTest {
public class AddExclusionIT extends AbstractSdkIT {

public DistroProperties getDistroProperties() {
return DistroHelper.getDistroPropertiesFromFile(distroFile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import org.junit.Test;

public class BuildDistroIntegrationTest extends AbstractSdkIntegrationTest {
public class BuildDistroIT extends AbstractSdkIT {

@Test
public void testBuildDistroFromDistroFile() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import java.io.File;

public class BuildIntegrationTest extends AbstractSdkIntegrationTest {
public class BuildIT extends AbstractSdkIT {

private String serverId;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import static org.hamcrest.CoreMatchers.hasItem;
import static org.hamcrest.MatcherAssert.assertThat;

public class CloneIntegrationTest extends AbstractSdkIntegrationTest {
public class CloneIT extends AbstractSdkIT {

@Test
public void clone_shouldCloneRepository() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.junit.Before;
import org.junit.Test;

public class CreateProjectIntegrationTest extends AbstractSdkIntegrationTest {
public class CreateProjectIT extends AbstractSdkIT {

Model model;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.openmrs.maven.plugins;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openmrs.maven.plugins.model.Artifact;
Expand All @@ -16,7 +15,7 @@
import static org.openmrs.maven.plugins.SdkMatchers.hasUserOwa;
import static org.openmrs.maven.plugins.SdkMatchers.serverHasVersion;

public class DeployIntegrationTest extends AbstractSdkIntegrationTest {
public class DeployIT extends AbstractSdkIT {

private static String testServerId;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import java.io.File;

public class FetchIntegrationTest extends AbstractSdkIntegrationTest{
public class FetchIT extends AbstractSdkIT {

private final static String FETCH_DIRECTORY_NAME = "fetch";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import java.io.File;

public class PullIntegrationTest extends AbstractSdkIntegrationTest {
public class PullIT extends AbstractSdkIT {

private static final String OPENMRS_MODULE_IDGEN = "openmrs-module-idgen";
private static final String PULL_GOAL = "pull";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

public class RemoveDependencyTest extends AbstractSdkIntegrationTest {
public class RemoveDependencyIT extends AbstractSdkIT {

@Test
public void shouldRemoveExistingDependency() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
package org.openmrs.maven.plugins;

import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.MatcherAssert.assertThat;

import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.UUID;

import org.apache.commons.io.FileUtils;
import org.junit.Test;

public class ResetIntegrationTest extends AbstractSdkIntegrationTest {
public class ResetIT extends AbstractSdkIT {

@Test
public void reset_shouldResetExistingServer() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
import static org.openmrs.maven.plugins.SdkMatchers.hasPropertyEqualTo;
import static org.openmrs.maven.plugins.SdkMatchers.hasPropertyThatContains;
import static org.openmrs.maven.plugins.SdkMatchers.hasPropertyThatNotContains;
import static org.openmrs.maven.plugins.SdkMatchers.serverHasName;
import static org.openmrs.maven.plugins.SdkMatchers.serverHasDebugPort;
import static org.openmrs.maven.plugins.SdkMatchers.serverHasName;
import static org.openmrs.maven.plugins.SdkMatchers.serverHasVersion;

public class SetupIntegrationTest extends AbstractSdkIntegrationTest {
public class SetupIT extends AbstractSdkIT {

@Test
public void setup_shouldInstallRefapp2_3_1() throws Exception{
Expand Down
8 changes: 6 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,10 @@
<artifactId>maven-gpg-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!--
The surefire plugin will execute any tests all classes whose name starts with Test,
or ends with Test, Tests or TestCase. Unit tests should follow this convention.
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
Expand All @@ -550,7 +554,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.3.0</version>
<version>3.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
Expand All @@ -563,7 +567,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.5.0</version>
<version>3.4.1</version>
<executions>
<execution>
<id>attach-javadocs</id>
Expand Down

0 comments on commit a3cabd9

Please sign in to comment.