How to set up JASMINE using MAVEN-PLUGIN?

让人想犯罪 __ 提交于 2019-12-10 20:28:37

问题


I have a folder structure like

-root
   -pom.xml
   -service
   -web
      -pom.xml
      -src
         -main
         -test
            -java
            -javascript
                  -lib
                  -specRunner.js
                  -runner.html
                  -spec
                     -model
                     -view
                     -collection

I have written JASMINE test cases in the "spec" folder containing "model","views","collections".

I'm able to see my test results in runner.html.

Now i'm trying to integrate with MAVEN build. SO followed steps given in http://searls.github.io/jasmine-maven-plugin

But i'm getting build failure when doing mvn clean install and unable to see anything on localhost:8234 when doing mvn jasmine:bdd

I'm unable to find out what went wrong. The errors in console show something about require js.

Following is my POM.xml for jasmine-maven plugin

<plugin>
            <groupId>com.github.searls</groupId>
            <artifactId>jasmine-maven-plugin</artifactId>
            <version>1.3.1.5</version>
            <executions>
                <execution>
                    <goals>
                        <goal>test</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <jsSrcDir>${project.basedir}/src/main/webapp/js</jsSrcDir>
                <jsTestSrcDir>${project.basedir}/src/test/javascript</jsTestSrcDir>
                <specRunnerTemplate>REQUIRE_JS</specRunnerTemplate>
                <preloadSources>
                    <source>${project.basedir}/src/main/webapp/js/libs/require.js</source>
                </preloadSources>
            </configuration>
        </plugin>

Can anybody guide what is wrong or better provide some demo project (Backbone+Require+Jasmine) which is integrated with MAVEN build.

Thanks in Advance.

I read some blogs and tried editing my jasmine-maven plugin as follows

            <plugin>
           <groupId>com.github.searls</groupId>
           <artifactId>jasmine-maven-plugin</artifactId>
           <version>1.3.1.5</version>
           <executions>
               <execution>
                   <goals>
                      <goal>test</goal>
                   </goals>
                <configuration>
                    <debug>true</debug>
                    <specRunnerTemplate>REQUIRE_JS</specRunnerTemplate>
                    <sourceExcludes>
                        <exclude>lib/jasmine.js</exclude>
                        <exclude>lib/jasmine-html.js</exclude>
                        <!--<exclude>libs/text.js</exclude>-->
                    </sourceExcludes>

                    <preloadSources>
                        <source>${basedir}/src/main/webapp/js/libs/require.js</source>
                        <source>${basedir}/src/main/webapp/js/main.js</source>

                    </preloadSources>

                    <jsSrcDir>${basedir}/src/main/webapp/js</jsSrcDir>
                    <sourceIncludes>
                    <include>${basedir}/src/main/webapp/jslibs/*.js</include>
                    <!--<include>libs/jquery-1.9.1.js</include>
                        <include>libs/underscore-min.js</include>
                        <include>libs/backbone-min.js</include>
                        <include>libs/text.js</include>-->
                        <!--<include>../templates/*.tmpl</include>-->

                    </sourceIncludes> 
                    <haltOnFailure>true</haltOnFailure>
                    <jsTestSrcDir>${basedir}/src/test/javascript</jsTestSrcDir>
                    <serverPort>8234</serverPort>

                    <specIncludes>
                        <include>spec/**/*.js</include> 
                    </specIncludes>
                    <!--<specRunnerHtmlFileName>runner.html</specRunnerHtmlFileName>-->
                </configuration>
               </execution>
           </executions>
        </plugin>

Now i'm able to check the JASMINE specs in the console while mvn clean install as follows-

Caused by: net.sourceforge.htmlunit.corejs.javascript.JavaScriptException: Error: src/views/../../templates/menu.tmpl HTTP status: 404

I'm getting errors on template files (exceptions) not sure what this is about.

Any help on this?

Thanks.

来源:https://stackoverflow.com/questions/24241249/how-to-set-up-jasmine-using-maven-plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!