2013-05-03 142 views
2

我正在使用QUnit + Sinon.js,它在本地運行良好。 當我試圖將它構建成持續集成過程時,問題就出現了。 我正在使用js-test-driver框架能夠在持續集成環境中運行它。 在過去,我使用它沒有Sinon.js,它沒有任何問題。 但是在我加入了Sinon.js插件之後,它根本不起作用。 當我試圖運行我的測試中,它說:QUnit和Sinon.js持續集成

D:/my/project/url/contentTest.js:60: TypeError: qTest is not a function 
Total 0 tests (Passed: 0 Fails: 0 Errors: 0)(0.00 ms) 

我的JS測試驅動程序配置:

server: http://localhost:9879 

load: 
    # QUnit related files 
    - qunit/lib/equiv.js 
    - qunit/lib/QUnitAdapter.js 
    - qunit/plugin/sinon-1.6.0.js 
    - qunit/plugin/sinon-qunit-1.0.0.js 

    # Dependencies 
    - external/jquery/1.7.2/jquery.min.js 

    # Files under test 
    - content.js 

    # Tests 
    - contentTest.js 

有趣的是,有一個QUnit index.html文件效果很好(當我打開這個網站,每次測試通過):

<!DOCTYPE html> 
<html> 
<head> 
    <meta charset="utf-8"> 
    <title>my tests</title> 
    <link rel="stylesheet" href="./qunit/lib/qunit-1.11.0.css"> 
</head> 
<body> 
    <div id="qunit"></div> 
    <div id="qunit-fixture"></div> 

    <!-- core --> 
    <script src="./qunit/lib/qunit-1.11.0.js"></script> 
    <script src="./qunit/plugin/sinon-1.6.0.js"></script> 
    <script src="./qunit/plugin/sinon-qunit-1.0.0.js"></script> 

    <!-- dependencies --> 
    <script src="./external/jquery/1.7.2/jquery.min.js"></script> 

    <!-- under test --> 
    <script src="./content.js"></script> 

    <!-- tests --> 
    <script src="./contentTest.js"></script> 
</body> 
</html> 

因此,似乎有與JS測試驅動器和Sinon.js衝突。如果我刪除所有相關的Sinon.js測試和包含的sinon插件,那麼它就可以工作。 如果我只是刪除了與sinon相關的測試,它仍然失敗。 如果我不刪除sinon.js,但刪除所有測試並創建一個「ok(true)」斷言的emty測試,那麼它仍會失敗,並顯示相同的錯誤消息(contentTest.js:60:TypeError:qTest is not一個函數),但是我的測試文件只包含10行(當我的文件只包含10行時,它如何可能是第60行的錯誤?)。

謝謝大家提前幫忙!

回答

0

不是一個解決方案,但可能是一種獲取更多信息的方法:您可以從shell本地運行js-test-driver腳本嗎?它是否會產生類似的錯誤細節?至少,這會給你更多的信息和更短的反饋循環。