Versions Compared

Key

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

In order to introduce TDD4C to you logic, you need to use Pricefx Studio or packaging to be able to fetch logics from the server. Then, set up a Git repo for your project, which will allow you to have continuous integration job on PFX Jenkins at Gitlab like https://nexusgitlab.pricefx.neteu/jenkins/viewtdd4c/tdd4c/.-example-logic

Create a Root pom.xml File

  1. Create a Maven metadata file where you enable Groovy usage and pull all the dependencies. Right click on the project root folder in Studio and choose New  > Create pom.xml from the menu. Or alternatively create the pom.xml file manually in the root folder of your project, looking like this one (substitute "myproject" with you project name). 

    Code Block
    languagexml
    linenumberstrue
    collapsetrue
    <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.13-groovy-2.4</spock.version>
    
            <!-- maven -->
            <maven-compiler-plugin.version>3.68.1</maven-compiler-plugin.version>
            <maven-surefire-plugin.version>2.22.20<1</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>
            <testSourceDirectory>tdd4c</testSourceDirectory>
            <plugins>
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>${maven-compiler-plugin.version}</version>
                    <configuration>
                        <source>${target.jdk}</source><release>11</release>
                        <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.9.5<0</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>addTestSources</goal>
                                <goal>testCompile<<goal>compileTests</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <testSources>
                            <testSource>
                                <directory>${basedir}/CalculationLogicTest</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 public maven artifacts</id>
                <url>https://nexus.pricefx.net/tools</url>
                <snapshots>
                    <enabled>true</enabled>
                </snapshots>
                <releases>
                    <enabled>true</enabled>
                </releases>
            </repository>
        </repositories>
    </project>


  2. Reopen the project and choose "Add as Maven project" when  when prompted.
  3. Make sure you marked the CalculationLogicTest folder as Test Sources Root in IDEA. This should be done by default during the action Update Upgrade Studio Project Libraries.