我有一个自动化框架,它使用grunt任务来运行多个spec文件。一些使用预定义的套件运行,其他使用文件命名约定。每个spec文件平均有一个"描述"块,每个通常有多个"它"块。
我目前正在使用jasmine-spec-reporter,它会在每个规范文件后提供有用且详细的结果,如下所示:
------------------------------------
[chrome OS X 10.10 #1-78] PID: 1880
[chrome OS X 10.10 #1-78] Specs: /**/**/jenkins/workspace/Main Suites/tests/User_Management/smoke_student_does_something.js
[chrome OS X 10.10 #1-78]
[chrome OS X 10.10 #1-78] Using SauceLabs selenium server at http://*******
[chrome OS X 10.10 #1-78] Spec started
[chrome OS X 10.10 #1-78]
[chrome OS X 10.10 #1-78] 1 A student can link and unlink to another student account
[chrome OS X 10.10 #1-78] ✓ can link to another student account (33 secs)
[chrome OS X 10.10 #1-78] ✓ can unlink a student account (14 secs)
[chrome OS X 10.10 #1-78]
[chrome OS X 10.10 #1-78] Executed 2 of 2 specs SUCCESS in 46 secs.
[chrome OS X 10.10 #1-78] SauceLabs results available at http://saucelabs.com/jobs/*****************
[launcher] 5 instance(s) of WebDriver still running
在所有引用taskId并列出pass + failure的jasmine报告之后,Protractor给了我一个相当无用的摘要控制台输出。这就是量角器总结的样子:
....
[launcher] chrome #1-69 passed
[launcher] chrome #1-70 failed 1 test(s)
[launcher] chrome #1-73 passed
[launcher] chrome #1-71 passed
[launcher] chrome #1-75 passed
[launcher] chrome #1-72 passed
[launcher] chrome #1-79 passed
[launcher] chrome #1-74 passed
[launcher] chrome #1-80 passed
[launcher] chrome #1-81 passed
[launcher] chrome #1-82 passed
[launcher] chrome #1-84 passed
[launcher] chrome #1-83 passed
[launcher] chrome #1-85 passed
[launcher] chrome #1-88 passed
[launcher] chrome #1-87 passed
[launcher] chrome #1-86 passed
[launcher] chrome #1-76 passed
[launcher] chrome #1-89 passed
[launcher] chrome #1-90 passed
[launcher] chrome #1-91 passed
[launcher] chrome #1-92 passed
[launcher] chrome #1-78 passed
[launcher] chrome #1-93 passed
[launcher] chrome #1-95 passed
[launcher] chrome #1-77 passed
[launcher] chrome #1-96 passed
[launcher] chrome #1-94 failed 5 test(s)
[launcher] overall: 12 failed spec(s)
[launcher] Process exited with error code 1
>>
Warning: Tests failed, protractor exited with code: 1 Use --force to continue.
我的问题是,我希望查看所有规范文件的摘要,而不是taskIds,仅针对失败的规范,并且只有在它们全部运行完毕之后。 MVP将只是列表中失败的spec文件名或以易于阅读的格式(xml,html等)写入文件。下一次迭代我会得到"描述"和"它"与茉莉花记者相似的每个失败旁边的块描述,错误代码和酱油链接。
我通常在一个作业中有数百个spec文件,并且必须梳理所有单个结果只是为了追踪哪个spec文件失败非常烦人(因为我觉得自动生成的摘要应该有这些信息)。我真的不得不在控制台输出上执行ctrl + f"失败",只是看看哪些规格失败了。我想避免去找失败清单上的酱油,因为我们的工作运作是如何通过詹金斯组织的。一旦作业完成,控制台输出应该是一个简单的第一个源/参考,用于失败列表。
每个第三方记者的范围似乎只能达到spec文件级别。执行每个spec文件后,它会报告,然后继续执行下一个覆盖上一个报告的文件。我打开HTML或XML报告,它总是只有一个spec文件的结果。我似乎无法将任何信息带入多个spec文件的摘要中。我已经调整了"整合(全部)"设置,似乎都没有为所有spec文件构建报告。他们似乎一次只考虑一个文件。
我试过以下记者:
茉莉记者
茉莉规格 - 报告
量角器-jasmine2-HTML - 报告
茉莉JSON-测试 - 报道
我已经能够操纵量角器" reportSummary"代码直接给我我想要的大部分(酱油链接除外),但这并不理想,因为我必须说服他们采用它。这是我的总结的样子:
********************
* FAILED SPEC(S) *
********************
/Playground/Test_Spec_2.js failed 2 test(s)
can log in once
FAILURE: Expected false to be true, 'Didn't see home page'.
FAILURE: Expected false to be true, 'Didn't see link'.
can log in twice
PASSED
can log in thrice
FAILURE: Expected false to be true, 'Didn't see home page'.
/Playground/Test_Spec_3.js failed 1 test(s)
can login
FAILURE: Expected false to be true, 'Didn't see home page'.
********************
* SUMMARY *
********************
overall: 2/4 failed spec(s)
********************
我错过了使用那些茉莉花记者的事情吗?我的框架是不是按照我想要的方式与那些记者合作?我是否应该说服量角器人员用一些选项加强他们的总结记者?
答案 0 :(得分:0)
您可以在所有测试运行后加入所有报告。只需确保您在同一文件夹中拥有所需的所有测试
return browser.getCapabilities().then(function (caps) {
var sessionId = caps.get('webdriver.remote.sessionid');
var date = dateMethods.getCurrentDate();
var folder = 'test-results/reports-' + date;
jasmine.getEnv().addReporter(new yourReporter({
savePath: folder + '/report' + '-' + sessionId.substr(0, 5)
}));
});
然后你可以加入它们并删除文件夹(使用" fs"模块或类似的东西)或重命名它,以便每次运行时创建一个新文件夹
答案 1 :(得分:0)
我正在使用这位记者:https://www.npmjs.com/package/protractor-jasmine2-screenshot-reporter 我每天都会在我的spec文件中使用此代码完整报告所有规范文件
this.returnToday = function(sign){
var now = new Date();
var day = ("0" + now.getDate()).slice(-2);
var month = ("0" + (now.getMonth() + 1)).slice(-2);
return today = (month) + sign + (day) + sign + now.getFullYear();
}
我今天用于将日期返回到文件夹名称的方法是:
text = <<TEXT
| locator map = {{Location map
|Island of {{country}} <-- NESTED CURLY HERE
|relief=yes|caption=|float=center
|marksize=5|lat= 53.50073|long=-10.14984
}}
| coords = {{coord|12|12|}}
TEXT
field_name = "locator map"
re = %r[
#{Regexp.escape(field_name)} # find the key we want
\s* = \s* # then the equals sign
(?<curlies> # start subroutine (also the final capture region)
{{ # opening curlies, then
(?: # any number of
\g<curlies> # full curly tag
| # or
(?!{{). # any character that would not start a curly tag
)*
}} # then closing curlies
)
]xm # extended syntax, multiline matching
puts text[re, :curlies] # extract the curlies region
# => {{Location map
|Island of {{country}} <-- NESTED CURLY HERE
|relief=yes|caption=|float=center
|marksize=5|lat= 53.50073|long=-10.14984
}}
text[re, :curlies] = "SOMETHING" # replace it with something
puts text
# => | locator map = SOMETHING
| coords = {{coord|12|12|}}
答案 2 :(得分:0)
您可以使用所需的设计创建自己的记者。
为此,您可以覆盖以下茉莉花方法。
self.jasmineStarted = function(summary) {
};
self.suiteStarted = function(suite) {
};
self.specStarted = function(spec) {
};
self.specDone = function(spec) {
};
self.suiteDone = function(suite) {
};
self.jasmineDone = function() {
};
您可以浏览文档here。