简体   繁体   English

如何安装Jasmin:Velocity项目上的javascript测试工具

[英]How to install Jasmin: the javascript test tool on Velocity project

I am searching the web for installing jasmine in order to test my javascript files. 我正在网上搜索安装茉莉花,以测试我的javascript文件。 Most places assumes I will install it as a gem in a ruby project. 大多数地方都假设我会将其安装为Ruby项目中的宝石。 But I am running velocity / Java project. 但是我正在运行Velocity / Java项目。

How do I install it? 如何安装? And is there a nice and easy guide to explain step-by-step how to make it work? 并有一个很好且简单的指南来逐步说明如何使其工作吗?

There's a Maven plugin for that. 有一个Maven插件。 Here's an example of how to use it: 以下是使用方法的示例:

First, in you project's POM, configure the plugin to be executed : 首先,在您的项目的POM中, 配置要执行的插件

  <plugin>
    <groupId>com.github.searls</groupId>
    <artifactId>jasmine-maven-plugin</artifactId>
    <version>1.0.2-beta-5</version>
    <executions>
      <execution>
        <goals>
          <goal>test</goal>
        </goals>
      </execution>
    </executions>
    <configuration>
      <sourceIncludes>
        <!-- relative to $jsSrcDir, defined further down -->
        <include>js/prototype/prototype.js</include>
        <include>uicomponents/widgets/list/xlist.js</include>
        <include>uicomponents/suggest/suggest.js</include>
        <include>uicomponents/model/entityReference.js</include>
      </sourceIncludes>
      <specIncludes>
        <!-- relative to src/test/javascript/ -->
        <include>spec/**/*.js</include>
      </specIncludes>
      <jsSrcDir>${project.basedir}/src/main/webapp/resources</jsSrcDir>
    </configuration>
  </plugin>

Then write specifications, in src/test/javascript/spec/ , using Jasmine's standards. 然后使用Jasmine的标准在src/test/javascript/spec/编写规范。

Next time you mvn install your project, Jasmine tests will be executed as well, failing the build if something is wrong. 下次您mvn install项目时,还将执行Jasmine测试,如果出现问题,则构建失败。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM