[英]How to run ember-cli test in jenkins
如何在詹金斯中進行Ember-cli測試?
當前要運行測試,我添加了一個構建步驟“ Execute shell”,其中包含以下內容:
ember test --silent --config-file ${WORKSPACE}/testem.json > ${WORKSPACE}/xunit-ember-dev.xml;
但這不起作用,這是輸出
<testsuite name="Testem Tests" tests="0" failures="0" timestamp="Thu Feb 12 2015 14:20:24 GMT+0100 (CET)" time="0">
</testsuite>
如果我在工作區中手動執行與jenkins用戶相同的操作,則會得到預期的結果。
<testsuite name="Testem Tests" tests="70" failures="0" timestamp="Thu Feb 12 2015 15:06:40 GMT+0100 (CET)" time="15">
<testcase name="PhantomJS 1.9 Integration - Homepage: Should display the homepage"/>
<testcase name="PhantomJS 1.9 Integration - Profile: Should display the profile sections"/>
...
每當我讓詹金斯(Jenkins)運行測試時,他都找不到測試。
謝謝
只需添加一個運行的Execute Shell步驟:
npm run test > results.tap
此命令告訴npm運行名為test的腳本,並將輸出重定向到名為results.tap的文件。 (重定向到results.tap的目的是使您可以將該文件拿到生成TAP步驟后進行發布,並獲得漂亮的測試運行圖。)
在package.json中,應該有一個類似於以下的代碼塊:
"scripts": {
"start": "ember server",
"build": "ember build",
"test": "ember test"
},
(這是ember-cli 1.13.8的默認設置,可能早於此版本。)
使用這種方法,您無需在構建系統上全局安裝ember-cli:只需從項目的node_modules文件夾中將其提取即可。
請注意:您可能會發現一些博客/論壇帖子,告訴您運行npm run test | tee results.tap
npm run test | tee results.tap
。 這將運行測試,但是,它將吃掉返回代碼。 (如果測試運行失敗,則npm進程將以返回值1退出,但是由於您正在將輸出傳遞給第二個命令(tee),因此該命令的返回代碼就是jenkins看到的。最終結果是jenkins會將測試失敗解釋為成功,並繼續執行構建步驟。)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.