2015-06-18 58 views
0

我正在使用試用版webide並試圖從/ test-resources文件夾運行myqunittest.qunit.html。通過使用url /test-resources/myqunittest.qunit.html。但是,只要我嘗試運行它,它就會返回一個404錯誤。嘗試運行qunit測試時獲取404

這是定義資源的問題嗎?我不明白如何,可以找到view/Main.view.xml,但不是在測試資源文件夾中的任何東西(我試過只是創建一個簡單的JS或HTML文件包含一個單一的行,它仍然404 「D)。

我已經從qunit幫助頁面QUnit Testing Fundamentals直接複製了該頁面,這段代碼似乎意味着它應該只是在沒有任何其他應用的情況下工作。

我試過sap.ui.localResources和data-sap-ui-resourcesroots在這兩個html文件中的各種組合都無濟於事。

我的文件夾結構如下:

myapp 
    test-resources 
     myqunittest.qunit.html 
    view 
     Main.controller.js 
     Main.view.xml 
    index.html 

myqunittest.qunit.html

<html> 
<head> 
    <meta http-equiv="X-UA-Compatible" content="IE=edge" /> 

    <script id="sap-ui-bootstrap" 
    type="text/javascript" 
    src="resources/sap-ui-core.js" 
    data-sap-ui-theme="sap_bluecrystal" 
    data-sap-ui-noConflict="true"> 
    </script> 

    <link rel="stylesheet" href="resources/sap/ui/thirdparty/qunit.css" type="text/css" media="screen" /> 
    <script type="text/javascript" src="resources/sap/ui/thirdparty/qunit.js"></script> 
    <script type="text/javascript" src="resources/sap/ui/qunit/qunit-junit.js"></script> 
    <script type="text/javascript" src="resources/sap/ui/qunit/QUnitUtils.js"></script> 


</head> 
<body> 
    <div id="qunit"></div> 
</body> 
</html> 

的index.html

<!DOCTYPE HTML> 
<html> 
<head> 
    <meta http-equiv="X-UA-Compatible" content="IE=edge"> 
    <meta http-equiv='Content-Type' content='text/html;charset=UTF-8'/> 

    <script src="resources/sap-ui-core.js" 
      id="sap-ui-bootstrap" 
      data-sap-ui-libs="sap.m" 
      data-sap-ui-resourceroots='{"myapp": "./"}' 
      data-sap-ui-theme="sap_bluecrystal"> 
    </script> 

    <script> 
      sap.ui.localResources("view"); 

      var app = new sap.m.App({initialPage:"idMain"}); 
      var page = sap.ui.view({id:"idMain", viewName:"myapp.view.Main", type:sap.ui.core.mvc.ViewType.XML}); 
      app.addPage(page); 
      app.placeAt("content"); 
    </script> 

</head> 
<body class="sapUiBody" role="application"> 
    <div id="content"></div> 
</body> 
</html> 

回答

0

的SAP WebIDE增加了新app.json爲您創建一個項目。它包含此項:

{ 
    "path": "/test-resources", 
    "target": { 
     "type": "service", 
     "name": "sapui5", 
     "entryPath": "/test-resources" 
    }, 
    "description": "SAPUI5 Test Resources" 
} 

這與創建我自己的測試資源文件夾干擾(一個已經不存在的項目),並導致404錯誤。刪除此條目已解決了我的問題。

+0

而不是刪除這個條目,你可以簡單地將你自己的測試資源重命名爲任何其他名稱,如「測試」,它再次完美無瑕。因此,請不要改動neo-app.json,只需更改測試的目錄名稱即可。 –

1

在您的index.html您加載UI5相對到資源文件夾中的index.html

所以你的服務器上有另一個文件夾

myapp 
    resources 
     sap-ui-core.js 
    test-resources 
     myqunittest.qunit.html 
    view 
     Main.controller.js 
     Main.view.xml 
    index.html 

的問題是,你正在加載的核心也相對到您的測試資源。你可能需要去1個目錄。

所以myqunittest.qunit.html 引導更改爲

<script src="../resources/sap-ui-core.js" 

最好的問候, 托比亞斯

+0

不幸的是,你的建議沒有奏效。 404錯誤似乎表明它是實際的測試資源文件夾或其中找不到的文件,我不明白。 – pyro

相關問題