Skip to content

Commit

Permalink
#1 Refactor and add support for pending, throwing and undefined tests
Browse files Browse the repository at this point in the history
  • Loading branch information
oledid committed Jul 25, 2016
1 parent e2cf17a commit d3d80ed
Show file tree
Hide file tree
Showing 8 changed files with 264 additions and 42 deletions.
4 changes: 2 additions & 2 deletions features/escapingValue.feature
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ Feature: Escaping values
In order to be able to parse the service messages

Scenario: Escaping apostrophe
Given a string It's fun to test
Given a string It's fun to test things
When the string is escaped
Then the string should be It|'s fun to test
Then the string should be It|'s fun to test things
Scenario: Escaping line feed (\n) and carriage return (\r)
Given a haiku by Issa
Expand Down
114 changes: 96 additions & 18 deletions features/resources/cucumberJson.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"keyword": "Before ",
"result": {
"status": "passed",
"duration": 338990
"duration": 315747
},
"hidden": true,
"match": {
Expand All @@ -26,7 +26,7 @@
"name": "something",
"result": {
"status": "passed",
"duration": 261411
"duration": 241790
},
"line": 9,
"match": {
Expand All @@ -39,7 +39,7 @@
"name": "something",
"result": {
"status": "passed",
"duration": 102934
"duration": 101123
},
"line": 10,
"match": {
Expand All @@ -64,7 +64,7 @@
"keyword": "After ",
"result": {
"status": "passed",
"duration": 137045
"duration": 128894
},
"hidden": true,
"match": {
Expand Down Expand Up @@ -95,7 +95,7 @@
"keyword": "Before ",
"result": {
"status": "passed",
"duration": 84220
"duration": 91162
},
"hidden": true,
"match": {
Expand All @@ -108,7 +108,7 @@
"name": "something",
"result": {
"status": "passed",
"duration": 87238
"duration": 92671
},
"line": 15,
"match": {
Expand All @@ -121,7 +121,7 @@
"name": "something",
"result": {
"status": "passed",
"duration": 85729
"duration": 89049
},
"line": 16,
"match": {
Expand All @@ -134,7 +134,7 @@
"name": "the test should fail",
"result": {
"status": "failed",
"duration": 2089783,
"duration": 2151665,
"error_message": "AssertionError: expected true to equal false\n at World.<anonymous> (C:\\Git\\oledid\\cucumber-json-to-teamcity\\features\\resources\\mock.feature.steps.js:26:21)\n at nextTickCallbackWith0Args (node.js:420:9)\n at process._tickCallback (node.js:349:13)\n at Function.Module.runMain (module.js:443:11)\n at startup (node.js:139:18)"
},
"line": 17,
Expand All @@ -147,7 +147,7 @@
"keyword": "After ",
"result": {
"status": "passed",
"duration": 87237
"duration": 93275
},
"hidden": true,
"match": {
Expand Down Expand Up @@ -178,7 +178,7 @@
"keyword": "Before ",
"result": {
"status": "passed",
"duration": 85427
"duration": 86936
},
"hidden": true,
"match": {
Expand All @@ -191,7 +191,7 @@
"name": "something",
"result": {
"status": "passed",
"duration": 91162
"duration": 98708
},
"line": 21,
"match": {
Expand All @@ -204,7 +204,7 @@
"name": "something",
"result": {
"status": "passed",
"duration": 84823
"duration": 92973
},
"line": 22,
"match": {
Expand All @@ -228,7 +228,7 @@
"keyword": "After ",
"result": {
"status": "passed",
"duration": 84521
"duration": 83012
},
"hidden": true,
"match": {
Expand Down Expand Up @@ -259,7 +259,7 @@
"keyword": "Before ",
"result": {
"status": "passed",
"duration": 84521
"duration": 91464
},
"hidden": true,
"match": {
Expand All @@ -272,7 +272,7 @@
"name": "something",
"result": {
"status": "passed",
"duration": 97502
"duration": 132819
},
"line": 27,
"match": {
Expand All @@ -285,7 +285,7 @@
"name": "something",
"result": {
"status": "passed",
"duration": 90860
"duration": 98407
},
"line": 28,
"match": {
Expand All @@ -298,7 +298,7 @@
"name": "the test should throw an error",
"result": {
"status": "failed",
"duration": 120141,
"duration": 128290,
"error_message": "Error: I am an error\n at World.<anonymous> (C:\\Git\\oledid\\cucumber-json-to-teamcity\\features\\resources\\mock.feature.steps.js:33:11)\n at nextTickCallbackWith0Args (node.js:420:9)\n at process._tickCallback (node.js:349:13)\n at Function.Module.runMain (module.js:443:11)\n at startup (node.js:139:18)"
},
"line": 29,
Expand All @@ -311,7 +311,7 @@
"keyword": "After ",
"result": {
"status": "passed",
"duration": 85427
"duration": 89049
},
"hidden": true,
"match": {
Expand All @@ -330,6 +330,84 @@
}
],
"type": "scenario"
},
{
"id": "a-mock-feature;an-undefined-test",
"keyword": "Scenario",
"line": 32,
"name": "An undefined test",
"steps": [
{
"arguments": [],
"keyword": "Before ",
"result": {
"status": "passed",
"duration": 85427
},
"hidden": true,
"match": {
"location": "C:\\Git\\oledid\\cucumber-json-to-teamcity\\features\\resources\\mock.feature.steps.js:6"
}
},
{
"arguments": [],
"keyword": "Given ",
"name": "something",
"result": {
"status": "passed",
"duration": 94483
},
"line": 33,
"match": {
"location": "C:\\Git\\oledid\\cucumber-json-to-teamcity\\features\\resources\\mock.feature.steps.js:14"
}
},
{
"arguments": [],
"keyword": "When ",
"name": "something",
"result": {
"status": "passed",
"duration": 94180
},
"line": 34,
"match": {
"location": "C:\\Git\\oledid\\cucumber-json-to-teamcity\\features\\resources\\mock.feature.steps.js:14"
}
},
{
"arguments": [],
"keyword": "Then ",
"name": "the test is not defined",
"result": {
"status": "undefined"
},
"line": 35
},
{
"arguments": [],
"keyword": "After ",
"result": {
"status": "passed",
"duration": 87841
},
"hidden": true,
"match": {
"location": "C:\\Git\\oledid\\cucumber-json-to-teamcity\\features\\resources\\mock.feature.steps.js:10"
}
}
],
"tags": [
{
"name": "@mockup",
"line": 1
},
{
"name": "@undefined",
"line": 31
}
],
"type": "scenario"
}
],
"id": "a-mock-feature",
Expand Down
50 changes: 31 additions & 19 deletions features/resources/expectedOutput.txt
Original file line number Diff line number Diff line change
@@ -1,50 +1,62 @@
##teamcity[testSuiteStarted name='A passing test']
##teamcity[testStarted name='Before ' captureStandardOutput='false']
##teamcity[testFinished name='Before ' duration='990']
##teamcity[testFinished name='Before ' duration='747']
##teamcity[testStarted name='Given something' captureStandardOutput='false']
##teamcity[testFinished name='Given something' duration='411']
##teamcity[testFinished name='Given something' duration='790']
##teamcity[testStarted name='When something' captureStandardOutput='false']
##teamcity[testFinished name='When something' duration='934']
##teamcity[testFinished name='When something' duration='123']
##teamcity[testStarted name='Then the test should pass' captureStandardOutput='false']
##teamcity[testFinished name='Then the test should pass' duration='666']
##teamcity[testStarted name='After ' captureStandardOutput='false']
##teamcity[testFinished name='After ' duration='45']
##teamcity[testFinished name='After ' duration='894']
##teamcity[testSuiteFinished name='A passing test']
##teamcity[testSuiteStarted name='A failing test']
##teamcity[testStarted name='Before ' captureStandardOutput='false']
##teamcity[testFinished name='Before ' duration='220']
##teamcity[testFinished name='Before ' duration='162']
##teamcity[testStarted name='Given something' captureStandardOutput='false']
##teamcity[testFinished name='Given something' duration='238']
##teamcity[testFinished name='Given something' duration='671']
##teamcity[testStarted name='When something' captureStandardOutput='false']
##teamcity[testFinished name='When something' duration='729']
##teamcity[testFinished name='When something' duration='49']
##teamcity[testStarted name='Then the test should fail' captureStandardOutput='false']
##teamcity[testFailed name='ScenarioA failing test' message='AssertionError: expected true to equal false' details='|n at World.&lt;anonymous&gt; (C:\Git\oledid\cucumber-json-to-teamcity\features\resources\mock.feature.steps.js:26:21)|n at nextTickCallbackWith0Args (node.js:420:9)|n at process._tickCallback (node.js:349:13)|n at Function.Module.runMain (modul']
##teamcity[testFinished name='Then the test should fail' duration='783']
##teamcity[testFinished name='Then the test should fail' duration='665']
##teamcity[testStarted name='After ' captureStandardOutput='false']
##teamcity[testFinished name='After ' duration='237']
##teamcity[testFinished name='After ' duration='275']
##teamcity[testSuiteFinished name='A failing test']
##teamcity[testSuiteStarted name='A pending test']
##teamcity[testStarted name='Before ' captureStandardOutput='false']
##teamcity[testFinished name='Before ' duration='427']
##teamcity[testFinished name='Before ' duration='936']
##teamcity[testStarted name='Given something' captureStandardOutput='false']
##teamcity[testFinished name='Given something' duration='162']
##teamcity[testFinished name='Given something' duration='708']
##teamcity[testStarted name='When something' captureStandardOutput='false']
##teamcity[testFinished name='When something' duration='823']
##teamcity[testFinished name='When something' duration='973']
##teamcity[testStarted name='Then the test should be ignored' captureStandardOutput='false']
##teamcity[testFinished name='Then the test should be ignored' duration='NaN']
##teamcity[testStarted name='After ' captureStandardOutput='false']
##teamcity[testFinished name='After ' duration='521']
##teamcity[testFinished name='After ' duration='12']
##teamcity[testSuiteFinished name='A pending test']
##teamcity[testSuiteStarted name='A test that throws an error']
##teamcity[testStarted name='Before ' captureStandardOutput='false']
##teamcity[testFinished name='Before ' duration='521']
##teamcity[testFinished name='Before ' duration='464']
##teamcity[testStarted name='Given something' captureStandardOutput='false']
##teamcity[testFinished name='Given something' duration='502']
##teamcity[testFinished name='Given something' duration='819']
##teamcity[testStarted name='When something' captureStandardOutput='false']
##teamcity[testFinished name='When something' duration='860']
##teamcity[testFinished name='When something' duration='407']
##teamcity[testStarted name='Then the test should throw an error' captureStandardOutput='false']
##teamcity[testFailed name='ScenarioA test that throws an error' message='Error: I am an error' details='|n at World.&lt;anonymous&gt; (C:\Git\oledid\cucumber-json-to-teamcity\features\resources\mock.feature.steps.js:33:11)|n at nextTickCallbackWith0Args (node.js:420:9)|n at process._tickCallback (node.js:349:13)|n at Function.Module.runMain (module.js:443:11)|n at star']
##teamcity[testFinished name='Then the test should throw an error' duration='141']
##teamcity[testFinished name='Then the test should throw an error' duration='290']
##teamcity[testStarted name='After ' captureStandardOutput='false']
##teamcity[testFinished name='After ' duration='49']
##teamcity[testSuiteFinished name='A test that throws an error']
##teamcity[testSuiteStarted name='An undefined test']
##teamcity[testStarted name='Before ' captureStandardOutput='false']
##teamcity[testFinished name='Before ' duration='427']
##teamcity[testStarted name='Given something' captureStandardOutput='false']
##teamcity[testFinished name='Given something' duration='483']
##teamcity[testStarted name='When something' captureStandardOutput='false']
##teamcity[testFinished name='When something' duration='180']
##teamcity[testStarted name='Then the test is not defined' captureStandardOutput='false']
##teamcity[testFinished name='Then the test is not defined' duration='NaN']
##teamcity[testStarted name='After ' captureStandardOutput='false']
##teamcity[testFinished name='After ' duration='427']
##teamcity[testSuiteFinished name='A test that throws an error']
##teamcity[testFinished name='After ' duration='841']
##teamcity[testSuiteFinished name='An undefined test']
6 changes: 6 additions & 0 deletions features/resources/mock.feature
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,9 @@ Scenario: A test that throws an error
Given something
When something
Then the test should throw an error

@undefined
Scenario: An undefined test
Given something
When something
Then the test is not defined
2 changes: 0 additions & 2 deletions features/resources/mock.feature.steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,5 @@ module.exports = function () {
callback(null, "pending");
}
}

return null;
});
};
28 changes: 28 additions & 0 deletions features/testStates.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Feature: Test states
As a developer using TeamCity
I want to make sure that I can read the correct test states from TeamCity

Scenario: A passing test
Given a passing test
When I have translated it with this API
Then TeamCity should be able to see that it is a passing test

Scenario: A failing test
Given a failing test
When I have translated it with this API
Then TeamCity should be able to see that it is a failing test

Scenario: A pending test
Given a pending test
When I have translated it with this API
Then TeamCity should be able to see that it is a pending test

Scenario: A test that throws an error
Given a test that throws an error
When I have translated it with this API
Then TeamCity should be able to see that it is a test that throws an error

Scenario: An undefined test
Given an undefined test
When I have translated it with this API
Then TeamCity should be able to see that it is an undefined test
Loading

0 comments on commit d3d80ed

Please sign in to comment.