Created
November 11, 2012 07:50
-
-
Save msakamoto-sf/4054109 to your computer and use it in GitHub Desktop.
Java + Groovy + TestNG + Maven combination example1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package gjt1; | |
public class Calc1 { | |
int v1; | |
int v2; | |
def Calc1(int a, int b) { | |
v1 = a; | |
v2 = b; | |
} | |
int calc() { | |
v1 + v2; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package gjt1; | |
import org.testng.Assert; | |
import org.testng.annotations.Test; | |
public class Calc1Test { | |
@Test | |
public void calc1() { | |
Calc1 c1 = new Calc1(10, 20); | |
Assert.assertEquals(c1.calc(), 30); | |
} | |
@Test | |
public void calc2() { | |
Calc2 c2 = new Calc2(1, 2); | |
Assert.assertEquals(c2.calc(), 3); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package gjt1; | |
public class Calc2 { | |
private int v1; | |
private int v2; | |
public Calc2(int a, int b) { | |
v1 = a; | |
v2 = b; | |
} | |
public int calc() { | |
return v1 + v2; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package gjt1; | |
import org.testng.Assert; | |
import org.testng.annotations.Test; | |
public class Calc2Test { | |
@Test | |
public void calc1() { | |
Calc1 c1 = new Calc1(1, 2); | |
Assert.assertEquals(c1.calc(), 3); | |
} | |
@Test | |
public void calc2() { | |
Calc2 c2 = new Calc2(10, 20); | |
Assert.assertEquals(c2.calc(), 30); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>gjt1</groupId> | |
<artifactId>gjt1</artifactId> | |
<packaging>jar</packaging> | |
<version>1.0-SNAPSHOT</version> | |
<name>gjt1</name> | |
<url>http://maven.apache.org</url> | |
<dependencies> | |
<!-- | |
This leads | |
""" | |
Failed to execute goal org.codehaus.gmaven:gmaven-plugin:1.4:compile (default) | |
on project gjt1: Execution default of goal org.codehaus.gmaven:gmaven-plugin:1.4:compile failed: | |
An API incompatibility was encountered while executing | |
org.codehaus.gmaven:gmaven-plugin:1.4:compile: java.lang.NoSuchMethodError: | |
org.codehaus.groovy.ast.ModuleNode.getStarImports()Ljava/util/List; | |
""" | |
<dependency> | |
<groupId>org.codehaus.gmaven.runtime</groupId> | |
<artifactId>gmaven-runtime-1.8</artifactId> | |
<version>1.4</version> | |
</dependency> | |
--> | |
<dependency> | |
<groupId>org.codehaus.groovy</groupId> | |
<artifactId>groovy-all</artifactId> | |
<version>1.8.8</version> | |
</dependency> | |
<dependency> | |
<groupId>org.testng</groupId> | |
<artifactId>testng</artifactId> | |
<version>[6.8,)</version> | |
<scope>test</scope> | |
</dependency> | |
</dependencies> | |
<build> | |
<plugins> | |
<plugin> | |
<groupId>org.codehaus.gmaven</groupId> | |
<artifactId>gmaven-plugin</artifactId> | |
<version>1.4</version> | |
<configuration> | |
<providerSelection>1.8</providerSelection> | |
</configuration> | |
<executions> | |
<execution> | |
<goals> | |
<goal>generateStubs</goal> | |
<goal>compile</goal> | |
<goal>generateTestStubs</goal> | |
<goal>testCompile</goal> | |
</goals> | |
</execution> | |
</executions> | |
</plugin> | |
</plugins> | |
</build> | |
</project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment