Skip to content

Commit ea72d6b

Browse files
committed
Allow fast tests to execute during standard build
Use TestNG's test groups feature to distinguish between fast, self contained unit tests and slow integration tests that access external services. Move the latter ones to the integration test phase and disable them by default.
1 parent ef33c69 commit ea72d6b

26 files changed

+65
-15
lines changed

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,14 @@ Developer forum for [docker-java](https://groups.google.com/forum/?hl=de#!forum/
1616
* Maven 3.0.5
1717
* Docker daemon running
1818

19-
Maven may run tests during build process but tests are disabled by default. The tests are using a localhost instance of Docker, make sure that you have Docker running for tests to work. To run the tests you have to provide your https://www.docker.io/account/login/ information:
19+
Some of the tests are using a localhost instance of Docker and require manual setup.
20+
In order to enable an easy standard build, these integration tests are disabled by default.
2021

21-
$ mvn clean install -DskipTests=false -Ddocker.io.username=... -Ddocker.io.password=... -Ddocker.io.email=...
22+
To run the full set of tests, make sure you have a local Docker daemon running and hten provide your https://registry.hub.docker.com/account/login/ information via system properties:
23+
24+
$ mvn clean install -DskipITs=false -Ddocker.io.username=... -Ddocker.io.password=... -Ddocker.io.email=...
25+
26+
If you are using a remote Docker server, add its URL like this: `-Ddocker.io.url=http://...:2375`.
2227

2328
By default Docker server is using UNIX sockets for communication with the Docker client, however docker-java
2429
client uses TCP/IP to connect to the Docker server, so you will need to make sure that your Docker server is

pom.xml

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,10 @@
4040
</developers>
4141

4242
<properties>
43-
<skipTests>true</skipTests>
43+
<skipITs>true</skipITs>
4444

4545
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
46+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
4647
<jdk.debug>true</jdk.debug>
4748
<jdk.optimize>false</jdk.optimize>
4849
<jdk.source>1.6</jdk.source>
@@ -76,7 +77,8 @@
7677
<maven-jar-plugin.version>2.2</maven-jar-plugin.version>
7778
<maven-compiler-plugin.version>2.3.1</maven-compiler-plugin.version>
7879
<maven-release-plugin.version>2.3.1</maven-release-plugin.version>
79-
<maven-surefire-plugin.version>2.8.1</maven-surefire-plugin.version>
80+
<maven-surefire-plugin.version>2.17</maven-surefire-plugin.version>
81+
<maven-failsafe-plugin.version>2.17</maven-failsafe-plugin.version>
8082
<cobertura-maven-plugin.version>2.5.1</cobertura-maven-plugin.version>
8183
<maven-antrun-plugin.version>1.7</maven-antrun-plugin.version>
8284
</properties>
@@ -255,16 +257,6 @@
255257
</executions>
256258
</plugin>
257259

258-
<plugin>
259-
<groupId>org.apache.maven.plugins</groupId>
260-
<artifactId>maven-surefire-plugin</artifactId>
261-
<version>${maven-surefire-plugin.version}</version>
262-
<configuration>
263-
<skipTests>${skipTests}</skipTests>
264-
</configuration>
265-
</plugin>
266-
267-
268260
<plugin>
269261
<groupId>org.codehaus.mojo</groupId>
270262
<artifactId>cobertura-maven-plugin</artifactId>
@@ -329,6 +321,36 @@
329321
<goals>deploy nexus-staging:release</goals>
330322
</configuration>
331323
</plugin>
324+
325+
<plugin>
326+
<groupId>org.apache.maven.plugins</groupId>
327+
<artifactId>maven-surefire-plugin</artifactId>
328+
<version>${maven-surefire-plugin.version}</version>
329+
<configuration>
330+
<excludedGroups>integration</excludedGroups>
331+
</configuration>
332+
</plugin>
333+
334+
<plugin>
335+
<groupId>org.apache.maven.plugins</groupId>
336+
<artifactId>maven-failsafe-plugin</artifactId>
337+
<version>${maven-failsafe-plugin.version}</version>
338+
<executions>
339+
<execution>
340+
<goals>
341+
<goal>integration-test</goal>
342+
<goal>verify</goal>
343+
</goals>
344+
<configuration>
345+
<skipITs>${skipITs}</skipITs>
346+
<groups>integration</groups>
347+
<includes>
348+
<include>**/*Test.java</include>
349+
</includes>
350+
</configuration>
351+
</execution>
352+
</executions>
353+
</plugin>
332354
</plugins>
333355
</build>
334356

src/test/java/com/github/dockerjava/client/DockerClientTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
*
2323
* @author Konstantin Pelykh (kpelykh@gmail.com)
2424
*/
25+
@Test(groups = "integration")
2526
public class DockerClientTest extends AbstractDockerClientTest {
2627
public static final Logger LOG = LoggerFactory
2728
.getLogger(DockerClientTest.class);

src/test/java/com/github/dockerjava/core/command/AuthCmdImplTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import com.github.dockerjava.core.DockerClientBuilder;
1717
import com.github.dockerjava.core.DockerClientConfig;
1818

19+
@Test(groups = "integration")
1920
public class AuthCmdImplTest extends AbstractDockerClientTest {
2021

2122
@BeforeTest

src/test/java/com/github/dockerjava/core/command/BuildImageCmdImplTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import com.github.dockerjava.api.command.InspectImageResponse;
2929
import com.github.dockerjava.client.AbstractDockerClientTest;
3030

31+
@Test(groups = "integration")
3132
public class BuildImageCmdImplTest extends AbstractDockerClientTest {
3233

3334
@BeforeTest

src/test/java/com/github/dockerjava/core/command/CommitCmdImplTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import com.github.dockerjava.api.command.InspectImageResponse;
2323
import com.github.dockerjava.client.AbstractDockerClientTest;
2424

25+
@Test(groups = "integration")
2526
public class CommitCmdImplTest extends AbstractDockerClientTest {
2627

2728
@BeforeTest

src/test/java/com/github/dockerjava/core/command/ContainerDiffCmdImplTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.github.dockerjava.api.model.ChangeLog;
2424
import com.github.dockerjava.client.AbstractDockerClientTest;
2525

26+
@Test(groups = "integration")
2627
public class ContainerDiffCmdImplTest extends AbstractDockerClientTest {
2728

2829
@BeforeTest

src/test/java/com/github/dockerjava/core/command/CopyFileFromContainerCmdImplTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import static org.hamcrest.Matchers.*;
1414
import static org.hamcrest.MatcherAssert.assertThat;
1515

16+
@Test(groups = "integration")
1617
public class CopyFileFromContainerCmdImplTest extends AbstractDockerClientTest {
1718

1819
@BeforeTest

src/test/java/com/github/dockerjava/core/command/CreateContainerCmdImplTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import com.github.dockerjava.api.model.Volume;
2222
import com.github.dockerjava.client.AbstractDockerClientTest;
2323

24+
@Test(groups = "integration")
2425
public class CreateContainerCmdImplTest extends AbstractDockerClientTest {
2526

2627
@BeforeTest

src/test/java/com/github/dockerjava/core/command/EventsCmdImplTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.util.concurrent.ExecutorService;
2121
import java.util.concurrent.TimeUnit;
2222

23+
@Test(groups = "integration")
2324
public class EventsCmdImplTest extends AbstractDockerClientTest {
2425

2526
private static int KNOWN_NUM_EVENTS = 4;

0 commit comments

Comments
 (0)