3

I have a Maven project and I wan't to change the POM so that when I build the project (Clean + Install), after the compilation part, a set of protractor tests will start (opening selenium and doing several things), and only if the tests pass, the build itself passes.

I can't seem to find something that gives me this kind of functionality. Is is possible? and if so, How do I use it? We are currently using the 'com.github.eirslett' maven plugin for building and I was wondering if it is possible to add the protractor tests as a stage in this plugin. I can see that it supports unit testing with 'Karma' but not anything related to protractor.

Any help will be much appreciated!! Thanks :)

elmekiesIsrael
  • 133
  • 1
  • 3
  • 11

3 Answers3

3

You can use following maven plugin https://github.com/greengerong/maven-ng-protractor

and you can use it like this

<plugin>
  <groupId>com.github.greengerong</groupId>
  <artifactId>maven-ng-protractor</artifactId>
  <version>0.0.2</version>
  <configuration>
    <protractor>protractor</protractor>
    <configFile>yourconfig.js</configFile>
  </configuration>
  <executions>
    <execution>
    <id>ng-protractor</id>
    <phase>integration-test</phase>
    <goals>
       <goal>run</goal>
    </goals>
    </execution>
  </executions>
</plugin>
mrkernelpanic
  • 4,268
  • 4
  • 28
  • 52
  • Hei Elmekies,Have your really solved your problem? It seems the project is incomplete and it does not run at all. I have tried myself to run the demo part, but i got errors. Please have a look at : https://github.com/greengerong/maven-ng-protractor/issues/5 – Neo182 Feb 19 '17 at 14:44
0

I am using grunt to execute these test like below :-

       <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.2.1</version>
            <executions>
                <execution>
                    <id>Run Protractor Tests</id>
                    <phase>integration-test</phase>
                    <goals>
                        <goal>exec</goal>
                    </goals>
                    <configuration>
                        <executable>grunt${script.extension}</executable>
                        <arguments>
                            <argument>int-test</argument>
                        </arguments>
                        <workingDirectory>${basedir}/modules</workingDirectory>
                    </configuration>
                </execution>
            </executions>
        </plugin>
user666
  • 1,104
  • 12
  • 20
0

Even i tried the same and giving the following error

ERROR] Failed to execute goal com.github.greengerong:maven-ng-protractor:0.0.1:run (ng-protractor) on project maven-ng-protractor-demo: There were exceptions when run protractor test. There were protractor test failures. -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

MANTON
  • 1