build

Passing System Properties and Environment Variables to unit tests in Maven – Update

Unfortunately there was an bug in my previous post.

I had naively assumed that the syntax for environment variables was the same as for system properties but alas not.

The correct code is:


 <build>
        <defaultGoal>package</defaultGoal>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.4.2</version>
                <configuration>
                    <environmentVariables>
                        <SOME_ENV_VARIABLE>some value</SOME_ENV_VARIABLE>
                    </environmentVariables>
                    <systemProperties>
                        <property>
                            <name>acceptance.test.host</name>
                            <value>${acceptance.test.host}</value>
                        </property>
                    </systemProperties>
                 </configuration>
            </plugin>
        </plugins>
    </build>
  • Share/Bookmark

build
maven
sysadmin
testing
thoughtblog

Comments (0)

Permalink

Passing System Properties and Environment Variables to unit tests in Maven

This is a bit of dark magic …

<pre>
<build>
<defaultGoal>package</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.4.2</version>
<configuration>
<environmentVariables>
<SOME_ENV_VARIABLE>some value</SOME_ENV_VARIABLE>
</environmentVariables>
<systemProperties>
<property>
<name>someSystemProperty</name>
<value>${thisCanBePassedIn}</value>
</property>
</systemProperties>
</configuration>
</plugin>
</plugins>
</build>

I'm afraid I had to update this post as initially I naively assumed that the syntax for environment variables was the same as for system properties. As you can see from above, you have to actually put a separate xml tag in there for the variable.

By putting the value in ${} you can then pass it in with -DsomeSystemProperty from the command line when you do mvn clean install

e.g. :

mvn -DsomeSystemProperty=foobar clean install
  • Share/Bookmark

build
code
maven
testing
thoughtblog

Comments (0)

Permalink

Update the version of ant which is used by Intellij on osx

Open package contents of app.

Go into there and replace lib/ant with the version you wnat and downloaded.

  • Share/Bookmark

build

Comments (0)

Permalink

Change the title of ant junit report

<junitreport todir="${junit.report.html.dir}">
                <fileset dir="${junit.report.xml.dir}">
                    <include name="*.xml"/>
                </fileset>
                <report format="frames" todir="${junit.report.html.dir}">
                    <param name="TITLE" expression="${junit.configuration} test results." />
                </report>
            </junitreport>

You can pass parameters to the stylesheet as above, one of which is TITLE. YOu can also change the whole stylesheet by passing “styledir” in as a property.

  • Share/Bookmark

build

Comments (1)

Permalink

Cruise / Ant : Could not find log.xml

We just ran into this problem trying to configure ant to run in a different working directory using cruise.

Our original snippet looked like this:

 
                
        

We then added antWorkingDir="${build.dir}" to the ant target, which failed with a dodgy message like “could not find log.xml”. This was because we no longer needed the ${build.dir} when speciying the buildfile. The error was actually hidden up above in the log and was really saying “could not find build.xml”.

working code:

 
                
        
  • Share/Bookmark

build

Comments (0)

Permalink