我正在使用量角器運行一些角度e2e測試並獲得失敗的期望。使用shardTestFiles配置測試時,量角器toContain失敗:true
expect: Expected [ 'Integration Test Acquirer Automatically generated EUR,GBP,USD activated' ] to contain 'Integration Test Acquirer Automatically generated EUR'.
我在此期望使用的代碼是:
expect(processingPathListElement.count()).toEqual(1);
expect(processingPathListElement.getText()).toContain('Integration Test Acquirer Automatically generated EUR');
因此,「集成測試收購自動生成EUR」文本實際上是包含在「集成測試收購自動生成的歐元,英鎊,美元」 。
我應該提到,當我使用測試的分片(運行瀏覽器的多個實例而不是一個,並將測試劃分在其中)時,此測試僅失敗。測試運行在5個firefox實例中。另一件事是我使用的是包含,而不是查看整個字符串,並使用匹配器「toEqual」,因爲當我運行測試時,分割貨幣之間的空間(應該是「EUR,GBP,USD」最終成爲「歐元,英鎊,美元「)被刪除。我不在乎第二個問題,但我關心第一個問題。如果我刪除shardTestFiles: true
測試通過
capabilities: {
'browserName': 'firefox',
shardTestFiles: true,
maxInstances: 5
},
;再此問題只表現當我運行與配置的測試。
這裏是關於失敗的測試整個信息:
expect: Expected [ 'Integration Test Acquirer Automatically generated EUR,GBP,USD activated' ] to contain 'Integration Test Acquirer Automatically generated EUR'. Error: Failed expectation at null.<anonymous> (/Users/bamboo/bamboo-home/xml-data/build-dir/IOG-TESTFE61-JOB1/test/e2e/merchants/merchant/merchantMPOSSpec.js:177:69) at /usr/local/lib/node_modules/protractor/node_modules/jasminewd/index.js:94:14 at webdriver.promise.ControlFlow.runInNewFrame_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1640:20) at webdriver.promise.ControlFlow.runEventLoop_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1505:8) at wrapper [as _onTimeout] (timers.js:252:14) at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)expect: Expected [ 'Integration Test Acquirer Automatically generated EUR,GBP,USD activated' ] to contain 'GBP'. Error: Failed expectation at null.<anonymous> (/Users/bamboo/bamboo-home/xml-data/build-dir/IOG-TESTFE61-JOB1/test/e2e/merchants/merchant/merchantMPOSSpec.js:178:69) at /usr/local/lib/node_modules/protractor/node_modules/jasminewd/index.js:94:14 at webdriver.promise.ControlFlow.runInNewFrame_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1640:20) at webdriver.promise.ControlFlow.runEventLoop_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1505:8) at wrapper [as _onTimeout] (timers.js:252:14) at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)expect: Expected [ 'Integration Test Acquirer Automatically generated EUR,GBP,USD activated' ] to contain 'USD activated'. Error: Failed expectation at null.<anonymous> (/Users/bamboo/bamboo-home/xml-data/build-dir/IOG-TESTFE61-JOB1/test/e2e/merchants/merchant/merchantMPOSSpec.js:179:69) at /usr/local/lib/node_modules/protractor/node_modules/jasminewd/index.js:94:14 at webdriver.promise.ControlFlow.runInNewFrame_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1640:20) at webdriver.promise.ControlFlow.runEventLoop_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1505:8) at wrapper [as _onTimeout] (timers.js:252:14) at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
你說得對。非常感謝你。這是我的一個愚蠢的分心,因爲我新列表只包含一個元素,它適用於其他與本文相同的案例(即使在分片測試中)。如果測試不被分割,這個測試會通過,這是非常混亂的,並讓我認爲問題在別處。 另外,期望失敗的方式似乎很奇怪。它應該說它不能做到這一點,但要呈現兩個文本,並說一個不包含在另一個(實際上是)。 – pcatre 2015-02-10 10:24:22