Revision: 455a95ed0739
Author: Janne Härkönen <[email protected]>
Date: Fri Jun 17 03:38:54 2011
Log: Fixed statistics specs
http://code.google.com/p/robotframework/source/detail?r=455a95ed0739
Modified:
/utest/webcontent/spec/StatisticsSpec.js
=======================================
--- /utest/webcontent/spec/StatisticsSpec.js Tue Jun 14 06:07:42 2011
+++ /utest/webcontent/spec/StatisticsSpec.js Fri Jun 17 03:38:54 2011
@@ -1,23 +1,45 @@
window.output = {};
describe("Statistics", function () {
-
- beforeEach(function () {
- window.output.stats =
- [[["Critical Tests", 1,1,"","", ""],
- ["All Tests", 2,3,"","", ""]],
- [["first tag", 3,
0, "tagdoc", "critical", "title:url:::t2:u2"],
- ["second tag", 1, 0, "", "", ""]],
- [["Suite", 4, 0, "Suite", "", ""],
- ["Suite.Sub", 4, 0, "Suite.Sub", "", ""]]];
- });
-
- function verifyBasicStatAttributes(stat, label, pass, fail, doc) {
+ var totals = [
+ {label: "Critical Tests",
+ pass: 1,
+ fail: 1},
+ {label: "All Tests",
+ pass: 2,
+ fail: 3}
+ ];
+ var tags = [
+ {label: "first tag",
+ pass: 3,
+ fail: 0,
+ doc: "tagdoc",
+ info: "critical",
+ links: "title:url:::t2:u2"},
+ {label: "second tag",
+ pass: 1,
+ fail: 0}
+ ];
+ var suites = [
+ {label: "Suite",
+ pass: 4,
+ fail: 0,
+ name: "Suite"},
+ {label:"Suite.Sub",
+ pass: 4,
+ fail: 0,
+ name: "Sub"}
+ ];
+ var stats = window.stats.Statistics(totals, tags, suites);
+ var totalStats = stats.total;
+ var tagStats = stats.tag;
+ var suiteStats = stats.suite;
+
+ function verifyBasicStatAttributes(stat, label, pass, fail) {
expect(stat.label).toEqual(label);
expect(stat.pass).toEqual(pass);
expect(stat.fail).toEqual(fail);
- expect(stat.total).toEqual(pass+fail);
- expect(stat.doc).toEqual(doc);
+ expect(stat.total).toEqual(pass + fail);
}
function verifySuiteStatNames(stat, name, parentName) {
@@ -26,60 +48,78 @@
}
it("should contain critical stats", function () {
- var criticalstats = window.testdata.statistics().total[0];
- verifyBasicStatAttributes(criticalstats, 'Critical Tests', 1,
1, '');
+ verifyBasicStatAttributes(totalStats[0], 'Critical Tests', 1, 1);
});
it("should contain all stats", function () {
- var allstats = window.testdata.statistics().total[1];
- verifyBasicStatAttributes(allstats, 'All Tests', 2, 3, '');
+ verifyBasicStatAttributes(totalStats[1], 'All Tests', 2, 3);
});
it("should contain tag statistics", function () {
- var tagstats = window.testdata.statistics().tag;
- var firstTagStats = tagstats[0];
- verifyBasicStatAttributes(firstTagStats, 'first tag', 3,
0, 'tagdoc');
+ var firstTagStats = tagStats[0];
+ verifyBasicStatAttributes(firstTagStats, 'first tag', 3, 0);
+ expect(firstTagStats.doc).toEqual('tagdoc');
expect(firstTagStats.shownInfo).toEqual('(critical)');
- var secondTagStats = tagstats[1];
- verifyBasicStatAttributes(secondTagStats, 'second tag', 1, 0, '');
+ var secondTagStats = tagStats[1];
+ verifyBasicStatAttributes(secondTagStats, 'second tag', 1, 0);
expect(secondTagStats.shownInfo).toEqual('');
});
it("should contain tag stat links", function () {
- var tagWithLink = window.testdata.statistics().tag[0];
- expect(tagWithLink.links).toEqual([{title: "title", url: "url"},
- {title: "t2", url: "u2"}]);
- var tagWithNoLink = window.testdata.statistics().tag[1];
+ var tagWithLink = tagStats[0];
+ expect(tagWithLink.links).toEqual([
+ {title: "title", url: "url"},
+ {title: "t2", url: "u2"}
+ ]);
+ var tagWithNoLink = tagStats[1];
expect(tagWithNoLink.links).toEqual([])
});
it("should contain suite statistics", function () {
- var suitestats = window.testdata.statistics().suite[0];
- verifyBasicStatAttributes(suitestats, 'Suite', 4, 0, 'Suite');
+ var suitestats = suiteStats[0];
+ verifyBasicStatAttributes(suitestats, 'Suite', 4, 0);
});
it("should contain names and parent names for suite stats", function
() {
- var statNoParents = window.testdata.statistics().suite[0];
+ var statNoParents = suiteStats[0];
verifySuiteStatNames(statNoParents, 'Suite', '');
- var statWithParents = window.testdata.statistics().suite[1];
+ var statWithParents = suiteStats[1];
verifySuiteStatNames(statWithParents, 'Sub', 'Suite . ');
});
});
+
describe("Statistics percents and widths", function () {
-
- beforeEach(function (){
- window.output.stats =
- [[["Critical Tests", 0,0,"","", ""],
- ["All Tests", 2,1,"","", ""]],
- [["<0.1% failed", 2000, 1, "", "", ""],
- ["<0.1% passed", 1, 4000, "", "", ""],
- ["0% failed", 100, 0, "", "", ""],
- ["0% passed", 0, 30, "", "", ""],
- ["0% passed", 5005, 4995, "", "", ""]],
- []];
- });
+ var totals = [
+ {label: "Critical Tests",
+ pass: 0,
+ fail: 0},
+ {label: "All Tests",
+ pass:2,
+ fail:1}
+ ];
+ var tags = [
+ {label: "<0.1% failed",
+ pass: 2000,
+ fail: 1},
+ {label: "<0.1% passed",
+ pass: 1,
+ fail: 4000},
+ {label: "0% failed",
+ pass: 100,
+ fail: 0},
+ {label: "0% passed",
+ pass: 0,
+ fail: 30},
+ {label: "0% passed",
+ pass: 5005,
+ fail: 4995}
+ ]
+
+ var stats = window.stats.Statistics(totals, tags, []);
+ var totalStats = stats.total;
+ var tagStats = stats.tag;
function percentagesShouldBe(stat, passPercent, failPercent) {
expect(stat.passPercent).toEqual(passPercent);
@@ -91,43 +131,43 @@
expect(stat.failWidth).toEqual(failWidth);
}
- it("should count percentages and widths for zero tests to be zero",
function (){
- var stat = window.testdata.statistics().total[0];
+ it("should count percentages and widths for zero tests to be zero",
function () {
+ var stat = totalStats[0];
percentagesShouldBe(stat, 0, 0);
widthsShouldBe(stat, 0, 0);
});
- it("should round floats to one digit in percentages and widths",
function (){
- var stat = window.testdata.statistics().total[1];
+ it("should round floats to one digit in percentages and widths",
function () {
+ var stat = totalStats[1];
percentagesShouldBe(stat, 66.7, 33.3);
widthsShouldBe(stat, 66.7, 33.3);
});
- it("should guarantee that non-zero percentages are at least 0.1",
function (){
- var stat = window.testdata.statistics().tag[0];
+ it("should guarantee that non-zero percentages are at least 0.1",
function () {
+ var stat = tagStats[0];
percentagesShouldBe(stat, 99.9, 0.1);
- stat = window.testdata.statistics().tag[1];
+ stat = tagStats[1];
percentagesShouldBe(stat, 0.1, 99.9);
});
- it("should guarantee that non-zero widths are at least 1", function (){
- var stat = window.testdata.statistics().tag[0];
+ it("should guarantee that non-zero widths are at least 1", function ()
{
+ var stat = tagStats[0];
widthsShouldBe(stat, 99, 1);
- stat = window.testdata.statistics().tag[1];
+ stat = tagStats[1];
widthsShouldBe(stat, 1, 99);
});
- it("should handle pass/fail percentages and widths of 0 and 100",
function (){
- var stat = window.testdata.statistics().tag[2];
+ it("should handle pass/fail percentages and widths of 0 and 100",
function () {
+ var stat = tagStats[2];
percentagesShouldBe(stat, 100, 0);
widthsShouldBe(stat, 100, 0);
- stat = window.testdata.statistics().tag[3];
+ stat = tagStats[3];
percentagesShouldBe(stat, 0, 100);
widthsShouldBe(stat, 0, 100);
});
- it("should guarantee that widths do not add up to over 100", function
(){
- var stat = window.testdata.statistics().tag[4];
+ it("should guarantee that widths do not add up to over 100", function
() {
+ var stat = tagStats[4];
percentagesShouldBe(stat, 50.1, 50);
widthsShouldBe(stat, 50, 50);
});