jasmine maven插件jasmine:bdd工作mvn测试破坏构建

jasmine maven插件jasmine:bdd工作mvn测试破坏构建,jasmine,bdd,htmlunit,jasmine-maven-plugin,Jasmine,Bdd,Htmlunit,Jasmine Maven Plugin,我已经建立了一个maven项目,使用JasminMaven插件来测试我的javascript代码。插件的设置如下所示: <plugin> <groupId>com.github.searls</groupId> <artifactId>jasmine-maven-plugin</artifactId> <version>1.2.0.0&l

我已经建立了一个maven项目,使用JasminMaven插件来测试我的javascript代码。插件的设置如下所示:

        <plugin>
            <groupId>com.github.searls</groupId>
            <artifactId>jasmine-maven-plugin</artifactId>
            <version>1.2.0.0</version>
            <extensions>true</extensions>
            <executions>
                <execution>
                    <goals>
                        <goal>test</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <jsSrcDir>src/main/webapp/js</jsSrcDir>
                <jsTestSrcDir>src/test/javascript</jsTestSrcDir>
                <sourceIncludes>
                        <include>jquery-1.8.2.min.js</include>
                        <include>jquery-ui-1.8.13.custom.min.js</include>
                        <include>jquery.json-2.2.js</include>
                        <include>stylesheet.js</include>
                        <include>**/*.js</include>
                </sourceIncludes>
            </configuration>
        </plugin>
    registerDragSurface: function ( element, onDrag ) {

        // Wrap every drag surface registration in a closure
        // to preserve the given set of arguments as local variables
        (function($, element, dragdropsystem, onDrag) {

            // Register a mousemove event on the drag surface
            $(element).mousemove (function ( event ) {

                // If the user is dragging
                if (dragdropsystem.isDragging) {

                    // Call the onDrag method with 
                    // the given element and event
                    onDrag (element, event);
                }
            });

            // Register a mouseup event on the drag surface
            $(element).mouseup (function ( event ) {

                // If the user is dragging
                if (dragdropsystem.isDragging) {

                    // Call the onDragEnded function
                    dragdropsystem.onDragEnded();
                }

                // We are not dragging anymore, and
                // the left mousebutton has been released
                dragdropsystem.isDragging = false;
                dragdropsystem.isMouseDown = false;
            });

        })($, element, this, onDrag);
    },
然后我编写了一个jasmine规范来测试这个函数。代码如下:

describe("linkedforms.dragdrop", function() {

    var dragdrop = linkedforms.dragdrop;

    it("test that a drag surface can be registered and onDragCallback is called", function () {

        var dragSurface = {};
        var onDragCallback = jasmine.createSpy("onDragCallback");

        dragdrop.registerDragSurface(dragSurface, onDragCallback);
        dragdrop.isDragging = true;

        jQuery(dragSurface).trigger("mousemove");
        expect(onDragCallback).toHaveBeenCalled();
        expect(dragdrop.isDragging).toBe(true);

        jQuery(dragSurface).trigger("mouseup");
        expect(dragdrop.isDragging).toBe(false);
    });
});
我可以从命令行运行mvnjasmine:bdd,然后访问

    http://localhost:8234 
运行测试。这很好,我所有的规格都通过了。然后,我尝试使用mvn测试从maven运行测试,但它失败了。它说:

* Expected spy onDragCallback to have been called.
* Passed.
* Expected true to be false.

这使我怀疑jQuery事件系统在从mvn测试运行时,以及在HtmlUnit浏览器中运行时不能正常工作。有人知道如何解决这个问题吗?

我发现,如果我将jQuery实现从jQuery-1.8.2.min.js[production]更改为jQuery-1.8.2.js[development],它就会工作

有人知道为什么会这样吗