Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. To enable TDD4C, you need to

...

Create a Root pom.xml File

    Create a Maven metadata file where you enable Groovy usage and pull all the dependencies. In the root folder of your project, create the pom.xml file like this one (substitute "myproject" with you project name). 

    Paste code macro
    languagexml
    <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/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <groupId>net.pricefx.myproject</groupId>
        <artifactId>myproject-logic</artifactId>
        <version>1.0-SNAPSHOT</version>
        <name>Price f(x) MyProject Logic</name>
    
        <properties>
            <!-- testing -->
            <junit.version>4.12</junit.version>
            <spock.version>1.1-groovy-2.4</spock.version>
    
            <!-- maven -->
            <maven-compiler-plugin.version>3.6.1</maven-compiler-plugin.version>
            <maven-surefire-plugin.version>2.20</maven-surefire-plugin.version>
    
            <source.jdk>1.8</source.jdk>
            <target.jdk>1.8</target.jdk>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        </properties>
    
        <build>
            <plugins>
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>${maven-compiler-plugin.version}</version>
                    <configuration>
                        <source>${target.jdk}</source>
                        <target>${target.jdk}</target>
                        <forceJavacCompilerUse>true</forceJavacCompilerUse>
                    </configuration>
                    <executions>
                        <execution>
                            <phase>compile</phase>
                            <goals>
                                <goal>compile</goal>
                                <goal>testCompile</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.gmavenplus</groupId>
                    <artifactId>gmavenplus-plugin</artifactId>
                    <version>1.5</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>addTestSources</goal>
                                <goal>testCompile</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <testSources>
                            <testSource>
                                <directory>${basedir}/tdd4c</directory>
                                <includes>
                                    <include>**/*.groovy</include>
                                </includes>
                            </testSource>
                        </testSources>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    
        <dependencies>
    
            <!-- Test -->
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>${junit.version}</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.spockframework</groupId>
                <artifactId>spock-core</artifactId>
                <version>${spock.version}</version>
                <scope>test</scope>
                <exclusions>
                    <exclusion>
                        <groupId>org.codehaus.groovy</groupId>
                        <artifactId>groovy-all</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>net.pricefx</groupId>
                <artifactId>tdd4c</artifactId>
                <version>1.0-SNAPSHOT</version>
                <scope>test</scope>
            </dependency>
    
        </dependencies>
    
        <repositories>
            <repository>
                <id>Default repo</id>
                <url>http://repo1.maven.org/maven2</url>
                <snapshots>
                    <enabled>false</enabled>
                </snapshots>
                <releases>
                    <enabled>true</enabled>
                </releases>
            </repository>
    
            <repository>
                <id>Pricefx maven artifacts</id>
                <url>http://maven.pricefx.net/</url>
                <snapshots>
                    <enabled>true</enabled>
                </snapshots>
                <releases>
                    <enabled>true</enabled>
                </releases>
            </repository>
        </repositories>
    </project>
  1. Create the tdd4c folder in the project's root directory.
  2. Mark it as the test sources root in you favourite IDE. 
    Image Removedhave a dependancy on the tdd4c library, which is provided as a Maven artefact in Maven repository. If you simply follow the steps described in Create New Project, it will get downlaoded to the project automatically since it is already included in the built-in pom.xml.
  3. In order to run TDD4C tests using the continuous integration, your pipeline need to execute the mvn test commnad. This is already covered by the existing templates for GitLab, GitHub and BitBucket. So if you generate the pipeline configuration script using the context menu Pricefx > CI Deployment in Studio, you don't need to do anything else.

  4. Make sure you marked the CalculationLogicTest folder as Test Sources Root in IDEA. This should be done by default during the action Upgrade Studio Project Libraries.
    Image Added