Jacoco integration with an executable that runs the tests.

55 views
Skip to first unread message

uma....@gmail.com

unread,
Dec 7, 2018, 6:21:12 AM12/7/18
to JaCoCo and EclEmma Users
I have an eclipse application, there are scripted (*.js) tests which are automated integration tests which are being executed using an .exe file.

I'll need to do the jacoco coverage for these tests. How do I achieve that?

Here is the pom for running the scripted tests. I included maven-failsafe plugin but doesn't seem to do anything (not getting executed).

Any advises are greatly appreciated.

Thanks in advance

<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<prerequisites>
<maven>3.0</maven>
</prerequisites>

<groupId>com.mentor.vsx</groupId>
<artifactId>com.mentor.vsx.scriptedTests</artifactId>
<version>0.1.0-SNAPSHOT</version>

<properties>
<!-- Location of the builds -->
<!-- ${CM_BRANCH_NAME} examples: "trunk", "VSA2016.1_maint", "VSA2016.2_maint",
etc. -->
<!-- <CM_BRANCH_NAME>trunk</CM_BRANCH_NAME> -->
<rootDeployLocation>//svr-hub-net-01.hub.mentorg.com/HUB-WKGP/RND/Projects/VSA/Temporary Builds/${CM_BRANCH_NAME}</rootDeployLocation>
<buildDir>${rootDeployLocation}\VSA_Build\</buildDir>
<VSA_COM.targetDir>${project.basedir}/target/VSA_COM</VSA_COM.targetDir>
<VSA_SCRIPT_PARAM_PRE_LOAD_NEEDED>true</VSA_SCRIPT_PARAM_PRE_LOAD_NEEDED>
<argLine>${jacoco.agent.argLine}</argLine>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.17</version>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<argLine>${jacoco.agent.argLine}</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.8</version>
<configuration>
<propertyName>jacoco.agent.argLine</propertyName>
</configuration>
<executions>
<execution>
<id>jacoco-initialize</id>
<phase>test</phase>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<tasks>
<echo> ${jacoco.agent.argLine} </echo>
</tasks>
<dataFile>${project.basedir}/target/jacoco.exec</dataFile>
<propertyName>jacoco.agent.argLine</propertyName>
</configuration>
</execution>
<execution>
<id>jacoco-report</id>
<phase>install</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<dataFile>${project.basedir}/target/jacoco.exec</dataFile>
<outputDirectory>${project.basedir}/target/jacoco/report</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>generate-extract-test-resources</id>
<phase>generate-test-resources</phase>
<configuration>
<target>
<taskdef resource="net/sf/antcontrib/antcontrib.properties" />
<taskdef resource="net/sf/antcontrib/antlib.xml" />
<loadproperties srcFile="${project.basedir}/test.properties"/>
<property name="VSA_SCRIPT_PARAM_EXPORT_TG_TDIR" value = "${project.basedir}/target/${EXPORT_TYPE}"/>
<property name="VSA_SCRIPT_PROPERTY_FILE" value="${VSA_COM.targetDir}/${VSA_SCRIPT_FILE}.properties"/>
<echo>Getting latest VSA_COM...</echo>
<timestampselector property="VSA_COM.latest">
<path>
<!-- <fileset dir="${buildDir}">
<include name="**/VSA_COM/*64.zip" />
</fileset> -->
<fileset dir="C:\vsa-com-git\vsa\vsa.com\features\com.mentor.vsa.product\target\products">
<include name="*.zip"/>
</fileset>
</path>
</timestampselector>
<unzip src="${VSA_COM.latest}" dest="${VSA_COM.targetDir}"
overwrite="true" />
<unzip dest="${project.basedir}/arInputFiles">
<fileset dir="${project.basedir}/arInputFiles">
<include name="*.zip" />
</fileset>
</unzip>
<replace file="${VSA_COM.targetDir}/Scripting.ini">
<replacetoken>Xmx8192m</replacetoken>
<replacevalue>Xmx16000m</replacevalue>
</replace>
<propertyfile file="${VSA_SCRIPT_PROPERTY_FILE}">
<entry key="${EXPORT_TYPE}TgtDir" value="${VSA_SCRIPT_PARAM_EXPORT_TG_TDIR}" />
<entry key="${EXPORT_TYPE}RefDir" value="${VSA_SCRIPT_PARAM_REF_DIR}" />
<entry key="serverAddress" value="${VSA_SCRIPT_PARAM_SERVER_ADDRESS}" />
<entry key="repositoryName" value="${VSA_SCRIPT_PARAM_REPOSITORY_NAME}" />
<entry key="serverPort" value="${VSA_SCRIPT_PARAM_SERVER_PORT}" />
<entry key="userName" value="${VSA_SCRIPT_PARAM_USERNAME}" />
<entry key="password" value="${VSA_SCRIPT_PARAM_PASSWORD}" />
<entry key="arFilesLocation" value="${project.basedir}/arInputFiles" />
<entry key="xsdLocation" value="${project.basedir}/xsds" />
<entry key="JOB_POSTFIX" value="jlr_vsa_19_1_ulade2_autotest" />
<entry key="CM_BRANCH_NAME" value="${CM_BRANCH_NAME}" />
<entry key="TestReportDir" value="${project.basedir}/target/surefire-reports" />
</propertyfile>
<mkdir dir="${VSA_SCRIPT_PARAM_EXPORT_TG_TDIR}"/>
<mkdir dir="${project.basedir}/target/surefire-reports"/>
<exec failonerror="true" dir="${VSA_COM.targetDir}" executable="${VSA_COM.targetDir}/Scripting.exe">
<arg line="-script ${project.basedir}/${VSA_SCRIPT_FILE} -argsFile ${VSA_SCRIPT_PROPERTY_FILE} ${argLine}" />
</exec>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>20030805.205232</version>
</dependency>
<dependency>
<groupId>ant</groupId>
<artifactId>ant-commons-net</artifactId>
<version>1.6.5</version>
</dependency>
<dependency>
<groupId>ant</groupId>
<artifactId>optional</artifactId>
<version>1.5.4</version>
</dependency>
<dependency>
<groupId>ant-contrib</groupId>
<artifactId>ant-contrib</artifactId>
<version>1.0b3</version>
<exclusions>
<exclusion>
<groupId>ant</groupId>
<artifactId>ant</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>

Marc Hoffmann

unread,
Dec 7, 2018, 7:38:08 AM12/7/18
to jac...@googlegroups.com
How do you start your application under test? At this point you need to provide ${jacoco.agent.argLine} to the JVM running your Eclipse application.

Regards,
-marc
> --
> You received this message because you are subscribed to the Google Groups "JaCoCo and EclEmma Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/838773ca-d5a4-4eed-b4ca-4eec0984e4cc%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Uma Lade

unread,
Dec 7, 2018, 8:30:36 AM12/7/18
to jac...@googlegroups.com
there is ant <exec> task to run the Java exe file (as you can see from the pom).   ${jacoco.agent.argLine} is set as a maven property.  The trick here is that there is maven-surefile-plugin or maven-falisafe-plugin being called... 

Scripting.exe program has the functionality to generate the sure-fire reports in the required directory.   

Without this maven plugin, jacoco plugin is not getting executed.   I'm struggling to find way around this.  Any guidance?

 <argLine>${jacoco.agent.argLine}</argLine>

<exec failonerror="true" dir="${VSA_COM.targetDir}" executable="${VSA_COM.targetDir}/Scripting.exe">
                                                                        <arg line="-script ${project.basedir}/${VSA_SCRIPT_FILE} -argsFile ${VSA_SCRIPT_PROPERTY_FILE} ${argLine}" />
                                                                </exec>

Thanks
Uma

You received this message because you are subscribed to a topic in the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jacoco/WgoEps2M7KA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jacoco+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/906B9647-7256-43C4-A5A0-C4BD3599B71B%40mountainminds.com.

Marc Hoffmann

unread,
Dec 7, 2018, 9:20:55 AM12/7/18
to jac...@googlegroups.com
Hi Uma,

so “Scripting.exe” is a Eclipse RCP app?

In this case you need to pass JVM parameters in the following format:

-vmargs ${argLine}

Note the -vmargs prefix. Please see Eclipse RCP documentation how the command line works:


Regards,
-marc


Uma Lade

unread,
Dec 11, 2018, 5:37:47 AM12/11/18
to jac...@googlegroups.com
Hi Marc,

Scripting.exe is not Eclipse RCP app, its a java scripting (javascript) engine.  

The pom I've (or I can change) has ant task to execute this engine (as an exe).  There are no other java class or test files, so can't use maven-surefire-plugin. 

I need a  way to generate coverage report.  Any suggestions?

Thanks in advance.

Regards
Uma



Evgeny Mandrikov

unread,
Dec 11, 2018, 7:31:07 AM12/11/18
to JaCoCo and EclEmma Users
Hi Uma,

Let me try to rephrase what Marc already said:
JaCoCo measures coverage of Java applications.
To do so this Java application under tests must be executed with JaCoCo agent - https://www.jacoco.org/jacoco/trunk/doc/agent.html
This is the only requirement, i.e. the way you test this application doesn't matter,
So please stop focusing on how you run tests and check how you start Java application under tests, which is so far completely unclear from your messages.

> To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+unsubscribe@googlegroups.com.

> To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/838773ca-d5a4-4eed-b4ca-4eec0984e4cc%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jacoco/WgoEps2M7KA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jacoco+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jacoco/WgoEps2M7KA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jacoco+unsubscribe@googlegroups.com.

Uma Lade

unread,
Dec 14, 2018, 5:13:26 AM12/14/18
to jac...@googlegroups.com
Hi Evgeny,

I'll try to make it clear. 

I've an executable Scripting.exe which is an eclipsec.exe and  invokes set of  java scripting (javascript) files which are in turn connect to Postgres DB testing some extracts. My requirement is to generate coverage reports for these tests.

The pom I have invokes an ant task to run Scripting.exe.  (This would be my AUT).    There are no other Junits present in this module. 

ant exec task from my pom:
<exec failonerror="true" dir="${VSA_COM.targetDir}" executable="${VSA_COM.targetDir}/Scripting.exe">
<arg line="-script ${project.basedir}/${VSA_SCRIPT_FILE} -argsFile ${VSA_SCRIPT_PROPERTY_FILE}" />
</exec>

How do I do the coverage for this application?  Any help is appreciated.

Thanks
Uma


Hi Uma,
> To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+un...@googlegroups.com.

> To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/838773ca-d5a4-4eed-b4ca-4eec0984e4cc%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jacoco/WgoEps2M7KA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jacoco+un...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+un...@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jacoco/WgoEps2M7KA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jacoco+un...@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jacoco/WgoEps2M7KA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jacoco+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/ff658582-541e-4109-84a0-fb5afd2f8b7a%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
Hi Uma,
> To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+un...@googlegroups.com.

> To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/838773ca-d5a4-4eed-b4ca-4eec0984e4cc%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jacoco/WgoEps2M7KA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jacoco+un...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+un...@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jacoco/WgoEps2M7KA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jacoco+un...@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jacoco/WgoEps2M7KA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jacoco+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/ff658582-541e-4109-84a0-fb5afd2f8b7a%40googlegroups.com.

Marc Hoffmann

unread,
Dec 14, 2018, 8:07:39 AM12/14/18
to jac...@googlegroups.com
Hi Uma,

if your AUT is not written in Java and not running on a Java Virtual Machine JaCoCo will not work for you. JaCoCo works for Java only.

Regards,
-marc


Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages