integration testing

This commit is contained in:
Mariusz Smykula
2016-03-26 19:07:53 +01:00
parent dc7c350e5a
commit 872940d0a9
4 changed files with 70 additions and 7 deletions

14
pom.xml
View File

@@ -56,12 +56,7 @@
<version>${mavenVersion}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
@@ -81,6 +76,13 @@
<version>2.8.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.takari.maven.plugins</groupId>
<artifactId>takari-plugin-integration-testing</artifactId>
<version>2.8.0</version>
<type>pom</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>

View File

@@ -0,0 +1,36 @@
package io.codearte.accurest.maven;
import java.io.File;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import io.takari.maven.testing.TestResources;
import io.takari.maven.testing.executor.MavenRuntime;
import io.takari.maven.testing.executor.MavenVersions;
import io.takari.maven.testing.executor.junit.MavenJUnitTestRunner;
@RunWith(MavenJUnitTestRunner.class)
@MavenVersions({ "3.3.3" })
public class PluginIntegrationTest {
@Rule
public final TestResources resources = new TestResources();
private final MavenRuntime maven;
public PluginIntegrationTest(MavenRuntime.MavenRuntimeBuilder mavenBuilder) throws Exception {
this.maven = mavenBuilder.withCliOptions("-B", "-U").build();
}
@Test
public void test() throws Exception {
File basedir = resources.getBasedir("basic-with-execution");
maven.forProject(basedir)
.withCliOption("-X")
.execute("package")
.assertErrorFreeLog()
.assertLogText("Accurest Plugin: Invoking GroovyDSL to WireMock client stubs conversion");
}
}

View File

@@ -13,8 +13,15 @@
<groupId>io.codearte.accurest</groupId>
<artifactId>accurest-maven-plugin</artifactId>
<version>${it-plugin.version}</version>
<extensions>true</extensions>
<executions>
<execution>
<goals>
<goal>generateStubs</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,18 @@
io.codearte.accurest.dsl.GroovyDsl.make {
request {
method 'POST'
url('/users') {
}
headers {
header 'Content-Type': 'application/json'
}
body '''{ "login" : "john", "name": "John The Contract" }'''
}
response {
status 200
headers {
header 'Location': '/users/john'
}
}
}