From fd5bc7cd643d72801512e2e01593e03ae31287da Mon Sep 17 00:00:00 2001 From: David Goss Date: Fri, 2 Aug 2024 14:20:17 -0400 Subject: [PATCH 01/18] add and extend schema definitions --- Makefile | 3 +++ jsonschema/Attachment.json | 3 +++ jsonschema/Envelope.json | 6 +++++ jsonschema/GlobalHookFinished.json | 28 ++++++++++++++++++++++ jsonschema/GlobalHookStarted.json | 24 +++++++++++++++++++ jsonschema/TestCase.json | 4 ++++ jsonschema/TestRunFinished.json | 3 +++ jsonschema/TestRunStarted.json | 3 +++ jsonschema/TestStepFinished.json | 37 +----------------------------- jsonschema/TestStepResult.json | 35 ++++++++++++++++++++++++++++ 10 files changed, 110 insertions(+), 36 deletions(-) create mode 100644 jsonschema/GlobalHookFinished.json create mode 100644 jsonschema/GlobalHookStarted.json create mode 100644 jsonschema/TestStepResult.json diff --git a/Makefile b/Makefile index a6968b72..2f537723 100644 --- a/Makefile +++ b/Makefile @@ -19,8 +19,11 @@ schemas = \ ./jsonschema/TestRunFinished.json \ ./jsonschema/TestRunStarted.json \ ./jsonschema/Duration.json \ + ./jsonschema/TestStepResult.json \ ./jsonschema/TestStepFinished.json \ ./jsonschema/TestStepStarted.json \ + ./jsonschema/GlobalHookFinished.json \ + ./jsonschema/GlobalHookStarted.json \ ./jsonschema/UndefinedParameterType.json \ ./jsonschema/Envelope.json diff --git a/jsonschema/Attachment.json b/jsonschema/Attachment.json index 91de12c9..5a88ac84 100644 --- a/jsonschema/Attachment.json +++ b/jsonschema/Attachment.json @@ -41,6 +41,9 @@ "url": { "description": "*\n A URL where the attachment can be retrieved. This field should not be set by Cucumber.\n It should be set by a program that reads a message stream and does the following for\n each Attachment message:\n\n - Writes the body (after base64 decoding if necessary) to a new file.\n - Sets `body` and `contentEncoding` to `null`\n - Writes out the new attachment message\n\n This will result in a smaller message stream, which can improve performance and\n reduce bandwidth of message consumers. It also makes it easier to process and download attachments\n separately from reports.", "type": "string" + }, + "testRunStartedId": { + "type": "string" } }, "type": "object" diff --git a/jsonschema/Envelope.json b/jsonschema/Envelope.json index e4e37f83..ccebf8d1 100644 --- a/jsonschema/Envelope.json +++ b/jsonschema/Envelope.json @@ -52,6 +52,12 @@ "testStepStarted": { "$ref": "./TestStepStarted.json" }, + "globalHookStarted": { + "$ref": "./GlobalHookStarted.json" + }, + "globalHookFinished": { + "$ref": "./GlobalHookFinished.json" + }, "undefinedParameterType": { "$ref": "./UndefinedParameterType.json" } diff --git a/jsonschema/GlobalHookFinished.json b/jsonschema/GlobalHookFinished.json new file mode 100644 index 00000000..8f1c7245 --- /dev/null +++ b/jsonschema/GlobalHookFinished.json @@ -0,0 +1,28 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "GlobalHookFinished.json", + "additionalProperties": false, + "required": [ + "testRunStartedId", + "hookId", + "result", + "timestamp" + ], + "properties": { + "testRunStartedId": { + "description": "Identifier for the test run that this hook execution belongs to", + "type": "string" + }, + "hookId": { + "description": "Identifier for the hook that was executed", + "type": "string" + }, + "result": { + "$ref": "./TestStepResult.json" + }, + "timestamp": { + "$ref": "./Timestamp.json" + } + }, + "type": "object" +} \ No newline at end of file diff --git a/jsonschema/GlobalHookStarted.json b/jsonschema/GlobalHookStarted.json new file mode 100644 index 00000000..2ad48233 --- /dev/null +++ b/jsonschema/GlobalHookStarted.json @@ -0,0 +1,24 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "GlobalHookStarted.json", + "additionalProperties": false, + "required": [ + "testRunStartedId", + "hookId", + "timestamp" + ], + "properties": { + "testRunStartedId": { + "description": "Identifier for the test run that this hook execution belongs to", + "type": "string" + }, + "hookId": { + "description": "Identifier for the hook that will be executed", + "type": "string" + }, + "timestamp": { + "$ref": "./Timestamp.json" + } + }, + "type": "object" +} \ No newline at end of file diff --git a/jsonschema/TestCase.json b/jsonschema/TestCase.json index 230127f5..937e0bd3 100644 --- a/jsonschema/TestCase.json +++ b/jsonschema/TestCase.json @@ -116,6 +116,10 @@ "$ref": "#/definitions/TestStep" }, "type": "array" + }, + "testRunStartedId": { + "description": "Identifier for the test run that this case belongs to", + "type": "string" } }, "type": "object" diff --git a/jsonschema/TestRunFinished.json b/jsonschema/TestRunFinished.json index 51b79a83..817a37dd 100644 --- a/jsonschema/TestRunFinished.json +++ b/jsonschema/TestRunFinished.json @@ -22,6 +22,9 @@ "exception": { "$ref": "./Exception.json", "description": "Any exception thrown during the test run, if any. Does not include exceptions thrown while executing steps." + }, + "testRunStartedId": { + "type": "string" } }, "type": "object" diff --git a/jsonschema/TestRunStarted.json b/jsonschema/TestRunStarted.json index 468a8e85..75358de3 100644 --- a/jsonschema/TestRunStarted.json +++ b/jsonschema/TestRunStarted.json @@ -8,6 +8,9 @@ "properties": { "timestamp": { "$ref": "./Timestamp.json" + }, + "id": { + "type": "string" } }, "type": "object" diff --git a/jsonschema/TestStepFinished.json b/jsonschema/TestStepFinished.json index c8ba99b8..69cca2ef 100644 --- a/jsonschema/TestStepFinished.json +++ b/jsonschema/TestStepFinished.json @@ -2,41 +2,6 @@ "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "TestStepFinished.json", "additionalProperties": false, - "definitions": { - "TestStepResult": { - "additionalProperties": false, - "required": [ - "duration", - "status" - ], - "properties": { - "duration": { - "$ref": "./Duration.json" - }, - "message": { - "type": "string", - "description": "An arbitrary bit of information that explains this result. This can be a stack trace of anything else." - }, - "status": { - "enum": [ - "UNKNOWN", - "PASSED", - "SKIPPED", - "PENDING", - "UNDEFINED", - "AMBIGUOUS", - "FAILED" - ], - "type": "string" - }, - "exception": { - "$ref": "./Exception.json", - "description": "Exception thrown while executing this step, if any." - } - }, - "type": "object" - } - }, "required": [ "testCaseStartedId", "testStepId", @@ -51,7 +16,7 @@ "type": "string" }, "testStepResult": { - "$ref": "#/definitions/TestStepResult" + "$ref": "./TestStepResult.json" }, "timestamp": { "$ref": "./Timestamp.json" diff --git a/jsonschema/TestStepResult.json b/jsonschema/TestStepResult.json new file mode 100644 index 00000000..fbbf16fc --- /dev/null +++ b/jsonschema/TestStepResult.json @@ -0,0 +1,35 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "TestStepResult.json", + "additionalProperties": false, + "required": [ + "duration", + "status" + ], + "properties": { + "duration": { + "$ref": "./Duration.json" + }, + "message": { + "type": "string", + "description": "An arbitrary bit of information that explains this result. This can be a stack trace of anything else." + }, + "status": { + "enum": [ + "UNKNOWN", + "PASSED", + "SKIPPED", + "PENDING", + "UNDEFINED", + "AMBIGUOUS", + "FAILED" + ], + "type": "string" + }, + "exception": { + "$ref": "./Exception.json", + "description": "Exception thrown while executing this step, if any." + } + }, + "type": "object" +} \ No newline at end of file From 017d4511473a38f43492cb339d10bdd4837ea84e Mon Sep 17 00:00:00 2001 From: David Goss Date: Fri, 2 Aug 2024 14:21:13 -0400 Subject: [PATCH 02/18] update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f73050ff..99351df2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] ### Added +- BREAKING CHANGE: Add `id` property to `TestRunStarted`, optionally reference in `Attachment`, TestCase` and `TestRunFinished` ([#102](https://github.com/cucumber/messages/pull/102)) +- Add new `GlobalHookStarted` and `GlobalHookFinished` messages ([#102](https://github.com/cucumber/messages/pull/102)) - [Dotnet] Added support classes aligned with what is provided for the Java implementation (https://github.com/cucumber/messages/pull/233 [clrudolphi](https://github.com/clrudolphi)) ### Changed From 773087fceecf46d54f25b73b841272e5408b1e00 Mon Sep 17 00:00:00 2001 From: David Goss Date: Fri, 2 Aug 2024 14:22:11 -0400 Subject: [PATCH 03/18] regenerate code --- .../messages/cucumber/messages/all.hpp | 2 + .../messages/cucumber/messages/attachment.hpp | 1 + .../messages/cucumber/messages/envelope.hpp | 4 + .../messages/global_hook_finished.hpp | 40 +++ .../cucumber/messages/global_hook_started.hpp | 38 +++ .../messages/cucumber/messages/test_case.hpp | 1 + .../cucumber/messages/test_run_finished.hpp | 1 + .../cucumber/messages/test_run_started.hpp | 1 + .../messages/cucumber/messages/attachment.cpp | 2 + .../messages/cucumber/messages/envelope.cpp | 4 + .../messages/global_hook_finished.cpp | 54 +++++ .../cucumber/messages/global_hook_started.cpp | 52 ++++ .../messages/cucumber/messages/test_case.cpp | 2 + .../cucumber/messages/test_run_finished.cpp | 2 + .../cucumber/messages/test_run_started.cpp | 2 + .../Cucumber.Messages/generated/Attachment.cs | 11 +- .../Cucumber.Messages/generated/Envelope.cs | 98 ++++++++ .../generated/GlobalHookFinished.cs | 93 +++++++ .../generated/GlobalHookStarted.cs | 85 +++++++ .../Cucumber.Messages/generated/TestCase.cs | 14 +- .../generated/TestRunFinished.cs | 11 +- .../generated/TestRunStarted.cs | 11 +- go/messages.go | 33 ++- .../cucumber/messages/types/Attachment.java | 16 +- .../io/cucumber/messages/types/Envelope.java | 102 ++++++++ .../messages/types/GlobalHookFinished.java | 87 +++++++ .../messages/types/GlobalHookStarted.java | 77 ++++++ .../io/cucumber/messages/types/TestCase.java | 19 +- .../messages/types/TestRunFinished.java | 16 +- .../messages/types/TestRunStarted.java | 16 +- javascript/src/messages.ts | 37 +++ messages.md | 23 ++ perl/lib/Cucumber/Messages.pm | 228 ++++++++++++++++++ php/src-generated/Attachment.php | 13 + php/src-generated/Envelope.php | 26 ++ php/src-generated/GlobalHookFinished.php | 114 +++++++++ php/src-generated/GlobalHookStarted.php | 98 ++++++++ php/src-generated/TestCase.php | 17 ++ php/src-generated/TestRunFinished.php | 13 + php/src-generated/TestRunStarted.php | 13 + ruby/lib/cucumber/messages/attachment.rb | 9 +- ruby/lib/cucumber/messages/envelope.rb | 10 + .../cucumber/messages/global_hook_finished.rb | 57 +++++ .../cucumber/messages/global_hook_started.rb | 52 ++++ ruby/lib/cucumber/messages/test_case.rb | 12 +- .../cucumber/messages/test_run_finished.rb | 9 +- .../lib/cucumber/messages/test_run_started.rb | 9 +- 47 files changed, 1600 insertions(+), 35 deletions(-) create mode 100644 cpp/include/messages/cucumber/messages/global_hook_finished.hpp create mode 100644 cpp/include/messages/cucumber/messages/global_hook_started.hpp create mode 100644 cpp/src/lib/messages/cucumber/messages/global_hook_finished.cpp create mode 100644 cpp/src/lib/messages/cucumber/messages/global_hook_started.cpp create mode 100644 dotnet/Cucumber.Messages/generated/GlobalHookFinished.cs create mode 100644 dotnet/Cucumber.Messages/generated/GlobalHookStarted.cs create mode 100644 java/src/generated/java/io/cucumber/messages/types/GlobalHookFinished.java create mode 100644 java/src/generated/java/io/cucumber/messages/types/GlobalHookStarted.java create mode 100644 php/src-generated/GlobalHookFinished.php create mode 100644 php/src-generated/GlobalHookStarted.php create mode 100644 ruby/lib/cucumber/messages/global_hook_finished.rb create mode 100644 ruby/lib/cucumber/messages/global_hook_started.rb diff --git a/cpp/include/messages/cucumber/messages/all.hpp b/cpp/include/messages/cucumber/messages/all.hpp index 4b4dc10c..a90d728e 100644 --- a/cpp/include/messages/cucumber/messages/all.hpp +++ b/cpp/include/messages/cucumber/messages/all.hpp @@ -17,6 +17,8 @@ #include #include #include +#include +#include #include #include #include diff --git a/cpp/include/messages/cucumber/messages/attachment.hpp b/cpp/include/messages/cucumber/messages/attachment.hpp index 3bfcbf0b..3e0cd97a 100644 --- a/cpp/include/messages/cucumber/messages/attachment.hpp +++ b/cpp/include/messages/cucumber/messages/attachment.hpp @@ -41,6 +41,7 @@ struct attachment std::optional test_case_started_id; std::optional test_step_id; std::optional url; + std::optional test_run_started_id; std::string to_string() const; diff --git a/cpp/include/messages/cucumber/messages/envelope.hpp b/cpp/include/messages/cucumber/messages/envelope.hpp index 0528621d..a6c3a236 100644 --- a/cpp/include/messages/cucumber/messages/envelope.hpp +++ b/cpp/include/messages/cucumber/messages/envelope.hpp @@ -22,6 +22,8 @@ #include #include #include +#include +#include #include namespace cucumber::messages { @@ -59,6 +61,8 @@ struct envelope std::optional test_run_started; std::optional test_step_finished; std::optional test_step_started; + std::optional global_hook_started; + std::optional global_hook_finished; std::optional undefined_parameter_type; std::string to_string() const; diff --git a/cpp/include/messages/cucumber/messages/global_hook_finished.hpp b/cpp/include/messages/cucumber/messages/global_hook_finished.hpp new file mode 100644 index 00000000..b298d620 --- /dev/null +++ b/cpp/include/messages/cucumber/messages/global_hook_finished.hpp @@ -0,0 +1,40 @@ +#pragma once + +#include +#include +#include + +#include + +#include +#include + +namespace cucumber::messages { + +using json = nlohmann::json; + +// +// Represents the GlobalHookFinished message in Cucumber's message protocol +// @see Github - Cucumber - Messages +// +// Generated code + +struct global_hook_finished +{ + std::string test_run_started_id; + std::string hook_id; + cucumber::messages::test_step_result result; + cucumber::messages::timestamp timestamp; + + std::string to_string() const; + + void to_json(json& j) const; + std::string to_json() const; +}; + +std::ostream& +operator<<(std::ostream& os, const global_hook_finished& msg); + +void to_json(json& j, const global_hook_finished& m); + +} diff --git a/cpp/include/messages/cucumber/messages/global_hook_started.hpp b/cpp/include/messages/cucumber/messages/global_hook_started.hpp new file mode 100644 index 00000000..5442c80d --- /dev/null +++ b/cpp/include/messages/cucumber/messages/global_hook_started.hpp @@ -0,0 +1,38 @@ +#pragma once + +#include +#include +#include + +#include + +#include + +namespace cucumber::messages { + +using json = nlohmann::json; + +// +// Represents the GlobalHookStarted message in Cucumber's message protocol +// @see Github - Cucumber - Messages +// +// Generated code + +struct global_hook_started +{ + std::string test_run_started_id; + std::string hook_id; + cucumber::messages::timestamp timestamp; + + std::string to_string() const; + + void to_json(json& j) const; + std::string to_json() const; +}; + +std::ostream& +operator<<(std::ostream& os, const global_hook_started& msg); + +void to_json(json& j, const global_hook_started& m); + +} diff --git a/cpp/include/messages/cucumber/messages/test_case.hpp b/cpp/include/messages/cucumber/messages/test_case.hpp index 146c0e6d..a5c726af 100644 --- a/cpp/include/messages/cucumber/messages/test_case.hpp +++ b/cpp/include/messages/cucumber/messages/test_case.hpp @@ -27,6 +27,7 @@ struct test_case std::string id; std::string pickle_id; std::vector test_steps; + std::optional test_run_started_id; std::string to_string() const; diff --git a/cpp/include/messages/cucumber/messages/test_run_finished.hpp b/cpp/include/messages/cucumber/messages/test_run_finished.hpp index d3213792..27cff76c 100644 --- a/cpp/include/messages/cucumber/messages/test_run_finished.hpp +++ b/cpp/include/messages/cucumber/messages/test_run_finished.hpp @@ -25,6 +25,7 @@ struct test_run_finished bool success; cucumber::messages::timestamp timestamp; std::optional exception; + std::optional test_run_started_id; std::string to_string() const; diff --git a/cpp/include/messages/cucumber/messages/test_run_started.hpp b/cpp/include/messages/cucumber/messages/test_run_started.hpp index 24f2fc62..bcf1a30d 100644 --- a/cpp/include/messages/cucumber/messages/test_run_started.hpp +++ b/cpp/include/messages/cucumber/messages/test_run_started.hpp @@ -21,6 +21,7 @@ using json = nlohmann::json; struct test_run_started { cucumber::messages::timestamp timestamp; + std::optional id; std::string to_string() const; diff --git a/cpp/src/lib/messages/cucumber/messages/attachment.cpp b/cpp/src/lib/messages/cucumber/messages/attachment.cpp index d4661e0c..ba133cdb 100644 --- a/cpp/src/lib/messages/cucumber/messages/attachment.cpp +++ b/cpp/src/lib/messages/cucumber/messages/attachment.cpp @@ -18,6 +18,7 @@ attachment::to_string() const cucumber::messages::to_string(oss, ", test_case_started_id=", test_case_started_id); cucumber::messages::to_string(oss, ", test_step_id=", test_step_id); cucumber::messages::to_string(oss, ", url=", url); + cucumber::messages::to_string(oss, ", test_run_started_id=", test_run_started_id); return oss.str(); } @@ -33,6 +34,7 @@ attachment::to_json(json& j) const cucumber::messages::to_json(j, camelize("test_case_started_id"), test_case_started_id); cucumber::messages::to_json(j, camelize("test_step_id"), test_step_id); cucumber::messages::to_json(j, camelize("url"), url); + cucumber::messages::to_json(j, camelize("test_run_started_id"), test_run_started_id); } std::string diff --git a/cpp/src/lib/messages/cucumber/messages/envelope.cpp b/cpp/src/lib/messages/cucumber/messages/envelope.cpp index 88e63702..6884c8a5 100644 --- a/cpp/src/lib/messages/cucumber/messages/envelope.cpp +++ b/cpp/src/lib/messages/cucumber/messages/envelope.cpp @@ -26,6 +26,8 @@ envelope::to_string() const cucumber::messages::to_string(oss, ", test_run_started=", test_run_started); cucumber::messages::to_string(oss, ", test_step_finished=", test_step_finished); cucumber::messages::to_string(oss, ", test_step_started=", test_step_started); + cucumber::messages::to_string(oss, ", global_hook_started=", global_hook_started); + cucumber::messages::to_string(oss, ", global_hook_finished=", global_hook_finished); cucumber::messages::to_string(oss, ", undefined_parameter_type=", undefined_parameter_type); return oss.str(); @@ -50,6 +52,8 @@ envelope::to_json(json& j) const cucumber::messages::to_json(j, camelize("test_run_started"), test_run_started); cucumber::messages::to_json(j, camelize("test_step_finished"), test_step_finished); cucumber::messages::to_json(j, camelize("test_step_started"), test_step_started); + cucumber::messages::to_json(j, camelize("global_hook_started"), global_hook_started); + cucumber::messages::to_json(j, camelize("global_hook_finished"), global_hook_finished); cucumber::messages::to_json(j, camelize("undefined_parameter_type"), undefined_parameter_type); } diff --git a/cpp/src/lib/messages/cucumber/messages/global_hook_finished.cpp b/cpp/src/lib/messages/cucumber/messages/global_hook_finished.cpp new file mode 100644 index 00000000..b7abbc43 --- /dev/null +++ b/cpp/src/lib/messages/cucumber/messages/global_hook_finished.cpp @@ -0,0 +1,54 @@ +#include + +#include +#include + +namespace cucumber::messages { + +std::string +global_hook_finished::to_string() const +{ + std::ostringstream oss; + + cucumber::messages::to_string(oss, "test_run_started_id=", test_run_started_id); + cucumber::messages::to_string(oss, ", hook_id=", hook_id); + cucumber::messages::to_string(oss, ", result=", result); + cucumber::messages::to_string(oss, ", timestamp=", timestamp); + + return oss.str(); +} + +void +global_hook_finished::to_json(json& j) const +{ + cucumber::messages::to_json(j, camelize("test_run_started_id"), test_run_started_id); + cucumber::messages::to_json(j, camelize("hook_id"), hook_id); + cucumber::messages::to_json(j, camelize("result"), result); + cucumber::messages::to_json(j, camelize("timestamp"), timestamp); +} + +std::string +global_hook_finished::to_json() const +{ + std::ostringstream oss; + json j; + + to_json(j); + + oss << j; + + return oss.str(); +} + +std::ostream& +operator<<(std::ostream& os, const global_hook_finished& msg) +{ + os << msg.to_string(); + + return os; +} + +void to_json(json& j, const global_hook_finished& m) +{ m.to_json(j); } + +} diff --git a/cpp/src/lib/messages/cucumber/messages/global_hook_started.cpp b/cpp/src/lib/messages/cucumber/messages/global_hook_started.cpp new file mode 100644 index 00000000..bdf3dac2 --- /dev/null +++ b/cpp/src/lib/messages/cucumber/messages/global_hook_started.cpp @@ -0,0 +1,52 @@ +#include + +#include +#include + +namespace cucumber::messages { + +std::string +global_hook_started::to_string() const +{ + std::ostringstream oss; + + cucumber::messages::to_string(oss, "test_run_started_id=", test_run_started_id); + cucumber::messages::to_string(oss, ", hook_id=", hook_id); + cucumber::messages::to_string(oss, ", timestamp=", timestamp); + + return oss.str(); +} + +void +global_hook_started::to_json(json& j) const +{ + cucumber::messages::to_json(j, camelize("test_run_started_id"), test_run_started_id); + cucumber::messages::to_json(j, camelize("hook_id"), hook_id); + cucumber::messages::to_json(j, camelize("timestamp"), timestamp); +} + +std::string +global_hook_started::to_json() const +{ + std::ostringstream oss; + json j; + + to_json(j); + + oss << j; + + return oss.str(); +} + +std::ostream& +operator<<(std::ostream& os, const global_hook_started& msg) +{ + os << msg.to_string(); + + return os; +} + +void to_json(json& j, const global_hook_started& m) +{ m.to_json(j); } + +} diff --git a/cpp/src/lib/messages/cucumber/messages/test_case.cpp b/cpp/src/lib/messages/cucumber/messages/test_case.cpp index 6a9070f3..c2af5362 100644 --- a/cpp/src/lib/messages/cucumber/messages/test_case.cpp +++ b/cpp/src/lib/messages/cucumber/messages/test_case.cpp @@ -13,6 +13,7 @@ test_case::to_string() const cucumber::messages::to_string(oss, "id=", id); cucumber::messages::to_string(oss, ", pickle_id=", pickle_id); cucumber::messages::to_string(oss, ", test_steps=", test_steps); + cucumber::messages::to_string(oss, ", test_run_started_id=", test_run_started_id); return oss.str(); } @@ -23,6 +24,7 @@ test_case::to_json(json& j) const cucumber::messages::to_json(j, camelize("id"), id); cucumber::messages::to_json(j, camelize("pickle_id"), pickle_id); cucumber::messages::to_json(j, camelize("test_steps"), test_steps); + cucumber::messages::to_json(j, camelize("test_run_started_id"), test_run_started_id); } std::string diff --git a/cpp/src/lib/messages/cucumber/messages/test_run_finished.cpp b/cpp/src/lib/messages/cucumber/messages/test_run_finished.cpp index f2c179e8..ce8ff84d 100644 --- a/cpp/src/lib/messages/cucumber/messages/test_run_finished.cpp +++ b/cpp/src/lib/messages/cucumber/messages/test_run_finished.cpp @@ -14,6 +14,7 @@ test_run_finished::to_string() const cucumber::messages::to_string(oss, ", success=", success); cucumber::messages::to_string(oss, ", timestamp=", timestamp); cucumber::messages::to_string(oss, ", exception=", exception); + cucumber::messages::to_string(oss, ", test_run_started_id=", test_run_started_id); return oss.str(); } @@ -25,6 +26,7 @@ test_run_finished::to_json(json& j) const cucumber::messages::to_json(j, camelize("success"), success); cucumber::messages::to_json(j, camelize("timestamp"), timestamp); cucumber::messages::to_json(j, camelize("exception"), exception); + cucumber::messages::to_json(j, camelize("test_run_started_id"), test_run_started_id); } std::string diff --git a/cpp/src/lib/messages/cucumber/messages/test_run_started.cpp b/cpp/src/lib/messages/cucumber/messages/test_run_started.cpp index 0ce5fdd9..5ef9a001 100644 --- a/cpp/src/lib/messages/cucumber/messages/test_run_started.cpp +++ b/cpp/src/lib/messages/cucumber/messages/test_run_started.cpp @@ -11,6 +11,7 @@ test_run_started::to_string() const std::ostringstream oss; cucumber::messages::to_string(oss, "timestamp=", timestamp); + cucumber::messages::to_string(oss, ", id=", id); return oss.str(); } @@ -19,6 +20,7 @@ void test_run_started::to_json(json& j) const { cucumber::messages::to_json(j, camelize("timestamp"), timestamp); + cucumber::messages::to_json(j, camelize("id"), id); } std::string diff --git a/dotnet/Cucumber.Messages/generated/Attachment.cs b/dotnet/Cucumber.Messages/generated/Attachment.cs index acb11b5d..c81d79be 100644 --- a/dotnet/Cucumber.Messages/generated/Attachment.cs +++ b/dotnet/Cucumber.Messages/generated/Attachment.cs @@ -73,6 +73,7 @@ public sealed class Attachment * separately from reports. */ public string Url { get; private set; } + public string TestRunStartedId { get; private set; } public Attachment( @@ -83,7 +84,8 @@ public Attachment( Source source, string testCaseStartedId, string testStepId, - string url + string url, + string testRunStartedId ) { RequireNonNull(body, "Body", "Attachment.Body cannot be null"); @@ -97,6 +99,7 @@ string url this.TestCaseStartedId = testCaseStartedId; this.TestStepId = testStepId; this.Url = url; + this.TestRunStartedId = testRunStartedId; } public override bool Equals(Object o) @@ -112,7 +115,8 @@ public override bool Equals(Object o) Object.Equals(Source, that.Source) && Object.Equals(TestCaseStartedId, that.TestCaseStartedId) && Object.Equals(TestStepId, that.TestStepId) && - Object.Equals(Url, that.Url); + Object.Equals(Url, that.Url) && + Object.Equals(TestRunStartedId, that.TestRunStartedId); } public override int GetHashCode() @@ -133,6 +137,8 @@ public override int GetHashCode() hash = hash * 31 + TestStepId.GetHashCode(); if (Url != null) hash = hash * 31 + Url.GetHashCode(); + if (TestRunStartedId != null) + hash = hash * 31 + TestRunStartedId.GetHashCode(); return hash; } @@ -147,6 +153,7 @@ public override string ToString() ", testCaseStartedId=" + TestCaseStartedId + ", testStepId=" + TestStepId + ", url=" + Url + + ", testRunStartedId=" + TestRunStartedId + '}'; } diff --git a/dotnet/Cucumber.Messages/generated/Envelope.cs b/dotnet/Cucumber.Messages/generated/Envelope.cs index 8c193a40..aabdcab4 100644 --- a/dotnet/Cucumber.Messages/generated/Envelope.cs +++ b/dotnet/Cucumber.Messages/generated/Envelope.cs @@ -39,6 +39,8 @@ public sealed class Envelope public TestRunStarted TestRunStarted { get; private set; } public TestStepFinished TestStepFinished { get; private set; } public TestStepStarted TestStepStarted { get; private set; } + public GlobalHookStarted GlobalHookStarted { get; private set; } + public GlobalHookFinished GlobalHookFinished { get; private set; } public UndefinedParameterType UndefinedParameterType { get; private set; } @@ -61,6 +63,8 @@ public static Envelope Create(Attachment attachment) null, null, null, + null, + null, null ); } @@ -84,6 +88,8 @@ public static Envelope Create(GherkinDocument gherkinDocument) null, null, null, + null, + null, null ); } @@ -107,6 +113,8 @@ public static Envelope Create(Hook hook) null, null, null, + null, + null, null ); } @@ -130,6 +138,8 @@ public static Envelope Create(Meta meta) null, null, null, + null, + null, null ); } @@ -153,6 +163,8 @@ public static Envelope Create(ParameterType parameterType) null, null, null, + null, + null, null ); } @@ -176,6 +188,8 @@ public static Envelope Create(ParseError parseError) null, null, null, + null, + null, null ); } @@ -199,6 +213,8 @@ public static Envelope Create(Pickle pickle) null, null, null, + null, + null, null ); } @@ -222,6 +238,8 @@ public static Envelope Create(Source source) null, null, null, + null, + null, null ); } @@ -245,6 +263,8 @@ public static Envelope Create(StepDefinition stepDefinition) null, null, null, + null, + null, null ); } @@ -268,6 +288,8 @@ public static Envelope Create(TestCase testCase) null, null, null, + null, + null, null ); } @@ -291,6 +313,8 @@ public static Envelope Create(TestCaseFinished testCaseFinished) null, null, null, + null, + null, null ); } @@ -314,6 +338,8 @@ public static Envelope Create(TestCaseStarted testCaseStarted) null, null, null, + null, + null, null ); } @@ -337,6 +363,8 @@ public static Envelope Create(TestRunFinished testRunFinished) null, null, null, + null, + null, null ); } @@ -360,6 +388,8 @@ public static Envelope Create(TestRunStarted testRunStarted) Require(testRunStarted, "TestRunStarted", "Envelope.TestRunStarted cannot be null"), null, null, + null, + null, null ); } @@ -383,6 +413,8 @@ public static Envelope Create(TestStepFinished testStepFinished) null, Require(testStepFinished, "TestStepFinished", "Envelope.TestStepFinished cannot be null"), null, + null, + null, null ); } @@ -406,6 +438,58 @@ public static Envelope Create(TestStepStarted testStepStarted) null, null, Require(testStepStarted, "TestStepStarted", "Envelope.TestStepStarted cannot be null"), + null, + null, + null + ); + } + + public static Envelope Create(GlobalHookStarted globalHookStarted) + { + return new Envelope( + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + Require(globalHookStarted, "GlobalHookStarted", "Envelope.GlobalHookStarted cannot be null"), + null, + null + ); + } + + public static Envelope Create(GlobalHookFinished globalHookFinished) + { + return new Envelope( + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + Require(globalHookFinished, "GlobalHookFinished", "Envelope.GlobalHookFinished cannot be null"), null ); } @@ -429,6 +513,8 @@ public static Envelope Create(UndefinedParameterType undefinedParameterType) null, null, null, + null, + null, Require(undefinedParameterType, "UndefinedParameterType", "Envelope.UndefinedParameterType cannot be null") ); } @@ -450,6 +536,8 @@ public Envelope( TestRunStarted testRunStarted, TestStepFinished testStepFinished, TestStepStarted testStepStarted, + GlobalHookStarted globalHookStarted, + GlobalHookFinished globalHookFinished, UndefinedParameterType undefinedParameterType ) { @@ -469,6 +557,8 @@ UndefinedParameterType undefinedParameterType this.TestRunStarted = testRunStarted; this.TestStepFinished = testStepFinished; this.TestStepStarted = testStepStarted; + this.GlobalHookStarted = globalHookStarted; + this.GlobalHookFinished = globalHookFinished; this.UndefinedParameterType = undefinedParameterType; } @@ -494,6 +584,8 @@ public override bool Equals(Object o) Object.Equals(TestRunStarted, that.TestRunStarted) && Object.Equals(TestStepFinished, that.TestStepFinished) && Object.Equals(TestStepStarted, that.TestStepStarted) && + Object.Equals(GlobalHookStarted, that.GlobalHookStarted) && + Object.Equals(GlobalHookFinished, that.GlobalHookFinished) && Object.Equals(UndefinedParameterType, that.UndefinedParameterType); } @@ -532,6 +624,10 @@ public override int GetHashCode() hash = hash * 31 + TestStepFinished.GetHashCode(); if (TestStepStarted != null) hash = hash * 31 + TestStepStarted.GetHashCode(); + if (GlobalHookStarted != null) + hash = hash * 31 + GlobalHookStarted.GetHashCode(); + if (GlobalHookFinished != null) + hash = hash * 31 + GlobalHookFinished.GetHashCode(); if (UndefinedParameterType != null) hash = hash * 31 + UndefinedParameterType.GetHashCode(); return hash; @@ -556,6 +652,8 @@ public override string ToString() ", testRunStarted=" + TestRunStarted + ", testStepFinished=" + TestStepFinished + ", testStepStarted=" + TestStepStarted + + ", globalHookStarted=" + GlobalHookStarted + + ", globalHookFinished=" + GlobalHookFinished + ", undefinedParameterType=" + UndefinedParameterType + '}'; } diff --git a/dotnet/Cucumber.Messages/generated/GlobalHookFinished.cs b/dotnet/Cucumber.Messages/generated/GlobalHookFinished.cs new file mode 100644 index 00000000..f4433604 --- /dev/null +++ b/dotnet/Cucumber.Messages/generated/GlobalHookFinished.cs @@ -0,0 +1,93 @@ +using System; +using System.Collections.Generic; + +// ------------------------------------------------------------------------------ +// This code was generated based on the Cucumber JSON schema +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// ------------------------------------------------------------------------------ + +namespace Io.Cucumber.Messages.Types; + +/** + * Represents the GlobalHookFinished message in Cucumber's message protocol + * @see Github - Cucumber - Messages + */ + +public sealed class GlobalHookFinished +{ + /** + * Identifier for the test run that this hook execution belongs to + */ + public string TestRunStartedId { get; private set; } + /** + * Identifier for the hook that was executed + */ + public string HookId { get; private set; } + public TestStepResult Result { get; private set; } + public Timestamp Timestamp { get; private set; } + + + public GlobalHookFinished( + string testRunStartedId, + string hookId, + TestStepResult result, + Timestamp timestamp + ) + { + RequireNonNull(testRunStartedId, "TestRunStartedId", "GlobalHookFinished.TestRunStartedId cannot be null"); + this.TestRunStartedId = testRunStartedId; + RequireNonNull(hookId, "HookId", "GlobalHookFinished.HookId cannot be null"); + this.HookId = hookId; + RequireNonNull(result, "Result", "GlobalHookFinished.Result cannot be null"); + this.Result = result; + RequireNonNull(timestamp, "Timestamp", "GlobalHookFinished.Timestamp cannot be null"); + this.Timestamp = timestamp; + } + + public override bool Equals(Object o) + { + if (this == o) return true; + if (o == null || this.GetType() != o.GetType()) return false; + GlobalHookFinished that = (GlobalHookFinished) o; + return + TestRunStartedId.Equals(that.TestRunStartedId) && + HookId.Equals(that.HookId) && + Result.Equals(that.Result) && + Timestamp.Equals(that.Timestamp); + } + + public override int GetHashCode() + { + int hash = 17; + if (TestRunStartedId != null) + hash = hash * 31 + TestRunStartedId.GetHashCode(); + if (HookId != null) + hash = hash * 31 + HookId.GetHashCode(); + if (Result != null) + hash = hash * 31 + Result.GetHashCode(); + if (Timestamp != null) + hash = hash * 31 + Timestamp.GetHashCode(); + return hash; + } + + public override string ToString() + { + return "GlobalHookFinished{" + + "testRunStartedId=" + TestRunStartedId + + ", hookId=" + HookId + + ", result=" + Result + + ", timestamp=" + Timestamp + + '}'; + } + + private static T Require(T property, string propertyName, string errorMessage) + { + RequireNonNull(property, propertyName, errorMessage); + return property; + } + private static void RequireNonNull(T property, string propertyName, string errorMessage) + { + if (property == null) throw new ArgumentNullException(propertyName, errorMessage); + } +} diff --git a/dotnet/Cucumber.Messages/generated/GlobalHookStarted.cs b/dotnet/Cucumber.Messages/generated/GlobalHookStarted.cs new file mode 100644 index 00000000..0e5cca1b --- /dev/null +++ b/dotnet/Cucumber.Messages/generated/GlobalHookStarted.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections.Generic; + +// ------------------------------------------------------------------------------ +// This code was generated based on the Cucumber JSON schema +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// ------------------------------------------------------------------------------ + +namespace Io.Cucumber.Messages.Types; + +/** + * Represents the GlobalHookStarted message in Cucumber's message protocol + * @see Github - Cucumber - Messages + */ + +public sealed class GlobalHookStarted +{ + /** + * Identifier for the test run that this hook execution belongs to + */ + public string TestRunStartedId { get; private set; } + /** + * Identifier for the hook that will be executed + */ + public string HookId { get; private set; } + public Timestamp Timestamp { get; private set; } + + + public GlobalHookStarted( + string testRunStartedId, + string hookId, + Timestamp timestamp + ) + { + RequireNonNull(testRunStartedId, "TestRunStartedId", "GlobalHookStarted.TestRunStartedId cannot be null"); + this.TestRunStartedId = testRunStartedId; + RequireNonNull(hookId, "HookId", "GlobalHookStarted.HookId cannot be null"); + this.HookId = hookId; + RequireNonNull(timestamp, "Timestamp", "GlobalHookStarted.Timestamp cannot be null"); + this.Timestamp = timestamp; + } + + public override bool Equals(Object o) + { + if (this == o) return true; + if (o == null || this.GetType() != o.GetType()) return false; + GlobalHookStarted that = (GlobalHookStarted) o; + return + TestRunStartedId.Equals(that.TestRunStartedId) && + HookId.Equals(that.HookId) && + Timestamp.Equals(that.Timestamp); + } + + public override int GetHashCode() + { + int hash = 17; + if (TestRunStartedId != null) + hash = hash * 31 + TestRunStartedId.GetHashCode(); + if (HookId != null) + hash = hash * 31 + HookId.GetHashCode(); + if (Timestamp != null) + hash = hash * 31 + Timestamp.GetHashCode(); + return hash; + } + + public override string ToString() + { + return "GlobalHookStarted{" + + "testRunStartedId=" + TestRunStartedId + + ", hookId=" + HookId + + ", timestamp=" + Timestamp + + '}'; + } + + private static T Require(T property, string propertyName, string errorMessage) + { + RequireNonNull(property, propertyName, errorMessage); + return property; + } + private static void RequireNonNull(T property, string propertyName, string errorMessage) + { + if (property == null) throw new ArgumentNullException(propertyName, errorMessage); + } +} diff --git a/dotnet/Cucumber.Messages/generated/TestCase.cs b/dotnet/Cucumber.Messages/generated/TestCase.cs index 440457b8..1394061d 100644 --- a/dotnet/Cucumber.Messages/generated/TestCase.cs +++ b/dotnet/Cucumber.Messages/generated/TestCase.cs @@ -26,12 +26,17 @@ public sealed class TestCase */ public string PickleId { get; private set; } public List TestSteps { get; private set; } + /** + * Identifier for the test run that this case belongs to + */ + public string TestRunStartedId { get; private set; } public TestCase( string id, string pickleId, - List testSteps + List testSteps, + string testRunStartedId ) { RequireNonNull(id, "Id", "TestCase.Id cannot be null"); @@ -40,6 +45,7 @@ List testSteps this.PickleId = pickleId; RequireNonNull>(testSteps, "TestSteps", "TestCase.TestSteps cannot be null"); this.TestSteps = new List(testSteps); + this.TestRunStartedId = testRunStartedId; } public override bool Equals(Object o) @@ -50,7 +56,8 @@ public override bool Equals(Object o) return Id.Equals(that.Id) && PickleId.Equals(that.PickleId) && - TestSteps.Equals(that.TestSteps); + TestSteps.Equals(that.TestSteps) && + Object.Equals(TestRunStartedId, that.TestRunStartedId); } public override int GetHashCode() @@ -62,6 +69,8 @@ public override int GetHashCode() hash = hash * 31 + PickleId.GetHashCode(); if (TestSteps != null) hash = hash * 31 + TestSteps.GetHashCode(); + if (TestRunStartedId != null) + hash = hash * 31 + TestRunStartedId.GetHashCode(); return hash; } @@ -71,6 +80,7 @@ public override string ToString() "id=" + Id + ", pickleId=" + PickleId + ", testSteps=" + TestSteps + + ", testRunStartedId=" + TestRunStartedId + '}'; } diff --git a/dotnet/Cucumber.Messages/generated/TestRunFinished.cs b/dotnet/Cucumber.Messages/generated/TestRunFinished.cs index f5d56804..83a9f40e 100644 --- a/dotnet/Cucumber.Messages/generated/TestRunFinished.cs +++ b/dotnet/Cucumber.Messages/generated/TestRunFinished.cs @@ -32,13 +32,15 @@ public sealed class TestRunFinished * Any exception thrown during the test run, if any. Does not include exceptions thrown while executing steps. */ public Exception Exception { get; private set; } + public string TestRunStartedId { get; private set; } public TestRunFinished( string message, bool success, Timestamp timestamp, - Exception exception + Exception exception, + string testRunStartedId ) { this.Message = message; @@ -47,6 +49,7 @@ Exception exception RequireNonNull(timestamp, "Timestamp", "TestRunFinished.Timestamp cannot be null"); this.Timestamp = timestamp; this.Exception = exception; + this.TestRunStartedId = testRunStartedId; } public override bool Equals(Object o) @@ -58,7 +61,8 @@ public override bool Equals(Object o) Object.Equals(Message, that.Message) && Success.Equals(that.Success) && Timestamp.Equals(that.Timestamp) && - Object.Equals(Exception, that.Exception); + Object.Equals(Exception, that.Exception) && + Object.Equals(TestRunStartedId, that.TestRunStartedId); } public override int GetHashCode() @@ -71,6 +75,8 @@ public override int GetHashCode() hash = hash * 31 + Timestamp.GetHashCode(); if (Exception != null) hash = hash * 31 + Exception.GetHashCode(); + if (TestRunStartedId != null) + hash = hash * 31 + TestRunStartedId.GetHashCode(); return hash; } @@ -81,6 +87,7 @@ public override string ToString() ", success=" + Success + ", timestamp=" + Timestamp + ", exception=" + Exception + + ", testRunStartedId=" + TestRunStartedId + '}'; } diff --git a/dotnet/Cucumber.Messages/generated/TestRunStarted.cs b/dotnet/Cucumber.Messages/generated/TestRunStarted.cs index 4cf6ac69..c415a075 100644 --- a/dotnet/Cucumber.Messages/generated/TestRunStarted.cs +++ b/dotnet/Cucumber.Messages/generated/TestRunStarted.cs @@ -17,14 +17,17 @@ namespace Io.Cucumber.Messages.Types; public sealed class TestRunStarted { public Timestamp Timestamp { get; private set; } + public string Id { get; private set; } public TestRunStarted( - Timestamp timestamp + Timestamp timestamp, + string id ) { RequireNonNull(timestamp, "Timestamp", "TestRunStarted.Timestamp cannot be null"); this.Timestamp = timestamp; + this.Id = id; } public override bool Equals(Object o) @@ -33,7 +36,8 @@ public override bool Equals(Object o) if (o == null || this.GetType() != o.GetType()) return false; TestRunStarted that = (TestRunStarted) o; return - Timestamp.Equals(that.Timestamp); + Timestamp.Equals(that.Timestamp) && + Object.Equals(Id, that.Id); } public override int GetHashCode() @@ -41,6 +45,8 @@ public override int GetHashCode() int hash = 17; if (Timestamp != null) hash = hash * 31 + Timestamp.GetHashCode(); + if (Id != null) + hash = hash * 31 + Id.GetHashCode(); return hash; } @@ -48,6 +54,7 @@ public override string ToString() { return "TestRunStarted{" + "timestamp=" + Timestamp + + ", id=" + Id + '}'; } diff --git a/go/messages.go b/go/messages.go index e7dc6169..3e9270e3 100644 --- a/go/messages.go +++ b/go/messages.go @@ -9,6 +9,7 @@ type Attachment struct { TestCaseStartedId string `json:"testCaseStartedId,omitempty"` TestStepId string `json:"testStepId,omitempty"` Url string `json:"url,omitempty"` + TestRunStartedId string `json:"testRunStartedId,omitempty"` } type Duration struct { @@ -33,6 +34,8 @@ type Envelope struct { TestRunStarted *TestRunStarted `json:"testRunStarted,omitempty"` TestStepFinished *TestStepFinished `json:"testStepFinished,omitempty"` TestStepStarted *TestStepStarted `json:"testStepStarted,omitempty"` + GlobalHookStarted *GlobalHookStarted `json:"globalHookStarted,omitempty"` + GlobalHookFinished *GlobalHookFinished `json:"globalHookFinished,omitempty"` UndefinedParameterType *UndefinedParameterType `json:"undefinedParameterType,omitempty"` } @@ -154,6 +157,19 @@ type Tag struct { Id string `json:"id"` } +type GlobalHookFinished struct { + TestRunStartedId string `json:"testRunStartedId"` + HookId string `json:"hookId"` + Result *TestStepResult `json:"result"` + Timestamp *Timestamp `json:"timestamp"` +} + +type GlobalHookStarted struct { + TestRunStartedId string `json:"testRunStartedId"` + HookId string `json:"hookId"` + Timestamp *Timestamp `json:"timestamp"` +} + type Hook struct { Id string `json:"id"` Name string `json:"name,omitempty"` @@ -290,9 +306,10 @@ type StepDefinitionPattern struct { } type TestCase struct { - Id string `json:"id"` - PickleId string `json:"pickleId"` - TestSteps []*TestStep `json:"testSteps"` + Id string `json:"id"` + PickleId string `json:"pickleId"` + TestSteps []*TestStep `json:"testSteps"` + TestRunStartedId string `json:"testRunStartedId,omitempty"` } type Group struct { @@ -333,14 +350,16 @@ type TestCaseStarted struct { } type TestRunFinished struct { - Message string `json:"message,omitempty"` - Success bool `json:"success"` - Timestamp *Timestamp `json:"timestamp"` - Exception *Exception `json:"exception,omitempty"` + Message string `json:"message,omitempty"` + Success bool `json:"success"` + Timestamp *Timestamp `json:"timestamp"` + Exception *Exception `json:"exception,omitempty"` + TestRunStartedId string `json:"testRunStartedId,omitempty"` } type TestRunStarted struct { Timestamp *Timestamp `json:"timestamp"` + Id string `json:"id,omitempty"` } type TestStepFinished struct { diff --git a/java/src/generated/java/io/cucumber/messages/types/Attachment.java b/java/src/generated/java/io/cucumber/messages/types/Attachment.java index 91e3fe25..3bf3401e 100644 --- a/java/src/generated/java/io/cucumber/messages/types/Attachment.java +++ b/java/src/generated/java/io/cucumber/messages/types/Attachment.java @@ -34,6 +34,7 @@ public final class Attachment { private final String testCaseStartedId; private final String testStepId; private final String url; + private final String testRunStartedId; public Attachment( String body, @@ -43,7 +44,8 @@ public Attachment( Source source, String testCaseStartedId, String testStepId, - String url + String url, + String testRunStartedId ) { this.body = requireNonNull(body, "Attachment.body cannot be null"); this.contentEncoding = requireNonNull(contentEncoding, "Attachment.contentEncoding cannot be null"); @@ -53,6 +55,7 @@ public Attachment( this.testCaseStartedId = testCaseStartedId; this.testStepId = testStepId; this.url = url; + this.testRunStartedId = testRunStartedId; } /** @@ -124,6 +127,10 @@ public Optional getUrl() { return Optional.ofNullable(url); } + public Optional getTestRunStartedId() { + return Optional.ofNullable(testRunStartedId); + } + @Override public boolean equals(Object o) { if (this == o) return true; @@ -137,7 +144,8 @@ public boolean equals(Object o) { Objects.equals(source, that.source) && Objects.equals(testCaseStartedId, that.testCaseStartedId) && Objects.equals(testStepId, that.testStepId) && - Objects.equals(url, that.url); + Objects.equals(url, that.url) && + Objects.equals(testRunStartedId, that.testRunStartedId); } @Override @@ -150,7 +158,8 @@ public int hashCode() { source, testCaseStartedId, testStepId, - url + url, + testRunStartedId ); } @@ -165,6 +174,7 @@ public String toString() { ", testCaseStartedId=" + testCaseStartedId + ", testStepId=" + testStepId + ", url=" + url + + ", testRunStartedId=" + testRunStartedId + '}'; } } diff --git a/java/src/generated/java/io/cucumber/messages/types/Envelope.java b/java/src/generated/java/io/cucumber/messages/types/Envelope.java index 9b764ba9..c2079898 100644 --- a/java/src/generated/java/io/cucumber/messages/types/Envelope.java +++ b/java/src/generated/java/io/cucumber/messages/types/Envelope.java @@ -37,6 +37,8 @@ public final class Envelope { private final TestRunStarted testRunStarted; private final TestStepFinished testStepFinished; private final TestStepStarted testStepStarted; + private final GlobalHookStarted globalHookStarted; + private final GlobalHookFinished globalHookFinished; private final UndefinedParameterType undefinedParameterType; public static Envelope of(Attachment attachment) { @@ -57,6 +59,8 @@ public static Envelope of(Attachment attachment) { null, null, null, + null, + null, null ); } @@ -79,6 +83,8 @@ public static Envelope of(GherkinDocument gherkinDocument) { null, null, null, + null, + null, null ); } @@ -101,6 +107,8 @@ public static Envelope of(Hook hook) { null, null, null, + null, + null, null ); } @@ -123,6 +131,8 @@ public static Envelope of(Meta meta) { null, null, null, + null, + null, null ); } @@ -145,6 +155,8 @@ public static Envelope of(ParameterType parameterType) { null, null, null, + null, + null, null ); } @@ -167,6 +179,8 @@ public static Envelope of(ParseError parseError) { null, null, null, + null, + null, null ); } @@ -189,6 +203,8 @@ public static Envelope of(Pickle pickle) { null, null, null, + null, + null, null ); } @@ -211,6 +227,8 @@ public static Envelope of(Source source) { null, null, null, + null, + null, null ); } @@ -233,6 +251,8 @@ public static Envelope of(StepDefinition stepDefinition) { null, null, null, + null, + null, null ); } @@ -255,6 +275,8 @@ public static Envelope of(TestCase testCase) { null, null, null, + null, + null, null ); } @@ -277,6 +299,8 @@ public static Envelope of(TestCaseFinished testCaseFinished) { null, null, null, + null, + null, null ); } @@ -299,6 +323,8 @@ public static Envelope of(TestCaseStarted testCaseStarted) { null, null, null, + null, + null, null ); } @@ -321,6 +347,8 @@ public static Envelope of(TestRunFinished testRunFinished) { null, null, null, + null, + null, null ); } @@ -343,6 +371,8 @@ public static Envelope of(TestRunStarted testRunStarted) { requireNonNull(testRunStarted, "Envelope.testRunStarted cannot be null"), null, null, + null, + null, null ); } @@ -365,6 +395,8 @@ public static Envelope of(TestStepFinished testStepFinished) { null, requireNonNull(testStepFinished, "Envelope.testStepFinished cannot be null"), null, + null, + null, null ); } @@ -387,6 +419,56 @@ public static Envelope of(TestStepStarted testStepStarted) { null, null, requireNonNull(testStepStarted, "Envelope.testStepStarted cannot be null"), + null, + null, + null + ); + } + + public static Envelope of(GlobalHookStarted globalHookStarted) { + return new Envelope( + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + requireNonNull(globalHookStarted, "Envelope.globalHookStarted cannot be null"), + null, + null + ); + } + + public static Envelope of(GlobalHookFinished globalHookFinished) { + return new Envelope( + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + requireNonNull(globalHookFinished, "Envelope.globalHookFinished cannot be null"), null ); } @@ -409,6 +491,8 @@ public static Envelope of(UndefinedParameterType undefinedParameterType) { null, null, null, + null, + null, requireNonNull(undefinedParameterType, "Envelope.undefinedParameterType cannot be null") ); } @@ -430,6 +514,8 @@ public Envelope( TestRunStarted testRunStarted, TestStepFinished testStepFinished, TestStepStarted testStepStarted, + GlobalHookStarted globalHookStarted, + GlobalHookFinished globalHookFinished, UndefinedParameterType undefinedParameterType ) { this.attachment = attachment; @@ -448,6 +534,8 @@ public Envelope( this.testRunStarted = testRunStarted; this.testStepFinished = testStepFinished; this.testStepStarted = testStepStarted; + this.globalHookStarted = globalHookStarted; + this.globalHookFinished = globalHookFinished; this.undefinedParameterType = undefinedParameterType; } @@ -515,6 +603,14 @@ public Optional getTestStepStarted() { return Optional.ofNullable(testStepStarted); } + public Optional getGlobalHookStarted() { + return Optional.ofNullable(globalHookStarted); + } + + public Optional getGlobalHookFinished() { + return Optional.ofNullable(globalHookFinished); + } + public Optional getUndefinedParameterType() { return Optional.ofNullable(undefinedParameterType); } @@ -541,6 +637,8 @@ public boolean equals(Object o) { Objects.equals(testRunStarted, that.testRunStarted) && Objects.equals(testStepFinished, that.testStepFinished) && Objects.equals(testStepStarted, that.testStepStarted) && + Objects.equals(globalHookStarted, that.globalHookStarted) && + Objects.equals(globalHookFinished, that.globalHookFinished) && Objects.equals(undefinedParameterType, that.undefinedParameterType); } @@ -563,6 +661,8 @@ public int hashCode() { testRunStarted, testStepFinished, testStepStarted, + globalHookStarted, + globalHookFinished, undefinedParameterType ); } @@ -586,6 +686,8 @@ public String toString() { ", testRunStarted=" + testRunStarted + ", testStepFinished=" + testStepFinished + ", testStepStarted=" + testStepStarted + + ", globalHookStarted=" + globalHookStarted + + ", globalHookFinished=" + globalHookFinished + ", undefinedParameterType=" + undefinedParameterType + '}'; } diff --git a/java/src/generated/java/io/cucumber/messages/types/GlobalHookFinished.java b/java/src/generated/java/io/cucumber/messages/types/GlobalHookFinished.java new file mode 100644 index 00000000..145e0d3a --- /dev/null +++ b/java/src/generated/java/io/cucumber/messages/types/GlobalHookFinished.java @@ -0,0 +1,87 @@ +package io.cucumber.messages.types; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +/** + * Represents the GlobalHookFinished message in Cucumber's message protocol + * @see Github - Cucumber - Messages + */ +// Generated code +@SuppressWarnings("unused") +public final class GlobalHookFinished { + private final String testRunStartedId; + private final String hookId; + private final TestStepResult result; + private final Timestamp timestamp; + + public GlobalHookFinished( + String testRunStartedId, + String hookId, + TestStepResult result, + Timestamp timestamp + ) { + this.testRunStartedId = requireNonNull(testRunStartedId, "GlobalHookFinished.testRunStartedId cannot be null"); + this.hookId = requireNonNull(hookId, "GlobalHookFinished.hookId cannot be null"); + this.result = requireNonNull(result, "GlobalHookFinished.result cannot be null"); + this.timestamp = requireNonNull(timestamp, "GlobalHookFinished.timestamp cannot be null"); + } + + /** + * Identifier for the test run that this hook execution belongs to + */ + public String getTestRunStartedId() { + return testRunStartedId; + } + + /** + * Identifier for the hook that was executed + */ + public String getHookId() { + return hookId; + } + + public TestStepResult getResult() { + return result; + } + + public Timestamp getTimestamp() { + return timestamp; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + GlobalHookFinished that = (GlobalHookFinished) o; + return + testRunStartedId.equals(that.testRunStartedId) && + hookId.equals(that.hookId) && + result.equals(that.result) && + timestamp.equals(that.timestamp); + } + + @Override + public int hashCode() { + return Objects.hash( + testRunStartedId, + hookId, + result, + timestamp + ); + } + + @Override + public String toString() { + return "GlobalHookFinished{" + + "testRunStartedId=" + testRunStartedId + + ", hookId=" + hookId + + ", result=" + result + + ", timestamp=" + timestamp + + '}'; + } +} diff --git a/java/src/generated/java/io/cucumber/messages/types/GlobalHookStarted.java b/java/src/generated/java/io/cucumber/messages/types/GlobalHookStarted.java new file mode 100644 index 00000000..cbf73810 --- /dev/null +++ b/java/src/generated/java/io/cucumber/messages/types/GlobalHookStarted.java @@ -0,0 +1,77 @@ +package io.cucumber.messages.types; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +/** + * Represents the GlobalHookStarted message in Cucumber's message protocol + * @see Github - Cucumber - Messages + */ +// Generated code +@SuppressWarnings("unused") +public final class GlobalHookStarted { + private final String testRunStartedId; + private final String hookId; + private final Timestamp timestamp; + + public GlobalHookStarted( + String testRunStartedId, + String hookId, + Timestamp timestamp + ) { + this.testRunStartedId = requireNonNull(testRunStartedId, "GlobalHookStarted.testRunStartedId cannot be null"); + this.hookId = requireNonNull(hookId, "GlobalHookStarted.hookId cannot be null"); + this.timestamp = requireNonNull(timestamp, "GlobalHookStarted.timestamp cannot be null"); + } + + /** + * Identifier for the test run that this hook execution belongs to + */ + public String getTestRunStartedId() { + return testRunStartedId; + } + + /** + * Identifier for the hook that will be executed + */ + public String getHookId() { + return hookId; + } + + public Timestamp getTimestamp() { + return timestamp; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + GlobalHookStarted that = (GlobalHookStarted) o; + return + testRunStartedId.equals(that.testRunStartedId) && + hookId.equals(that.hookId) && + timestamp.equals(that.timestamp); + } + + @Override + public int hashCode() { + return Objects.hash( + testRunStartedId, + hookId, + timestamp + ); + } + + @Override + public String toString() { + return "GlobalHookStarted{" + + "testRunStartedId=" + testRunStartedId + + ", hookId=" + hookId + + ", timestamp=" + timestamp + + '}'; + } +} diff --git a/java/src/generated/java/io/cucumber/messages/types/TestCase.java b/java/src/generated/java/io/cucumber/messages/types/TestCase.java index b7f99366..3cd74e3e 100644 --- a/java/src/generated/java/io/cucumber/messages/types/TestCase.java +++ b/java/src/generated/java/io/cucumber/messages/types/TestCase.java @@ -21,15 +21,18 @@ public final class TestCase { private final String id; private final String pickleId; private final java.util.List testSteps; + private final String testRunStartedId; public TestCase( String id, String pickleId, - java.util.List testSteps + java.util.List testSteps, + String testRunStartedId ) { this.id = requireNonNull(id, "TestCase.id cannot be null"); this.pickleId = requireNonNull(pickleId, "TestCase.pickleId cannot be null"); this.testSteps = unmodifiableList(new ArrayList<>(requireNonNull(testSteps, "TestCase.testSteps cannot be null"))); + this.testRunStartedId = testRunStartedId; } public String getId() { @@ -47,6 +50,13 @@ public java.util.List getTestSteps() { return testSteps; } + /** + * Identifier for the test run that this case belongs to + */ + public Optional getTestRunStartedId() { + return Optional.ofNullable(testRunStartedId); + } + @Override public boolean equals(Object o) { if (this == o) return true; @@ -55,7 +65,8 @@ public boolean equals(Object o) { return id.equals(that.id) && pickleId.equals(that.pickleId) && - testSteps.equals(that.testSteps); + testSteps.equals(that.testSteps) && + Objects.equals(testRunStartedId, that.testRunStartedId); } @Override @@ -63,7 +74,8 @@ public int hashCode() { return Objects.hash( id, pickleId, - testSteps + testSteps, + testRunStartedId ); } @@ -73,6 +85,7 @@ public String toString() { "id=" + id + ", pickleId=" + pickleId + ", testSteps=" + testSteps + + ", testRunStartedId=" + testRunStartedId + '}'; } } diff --git a/java/src/generated/java/io/cucumber/messages/types/TestRunFinished.java b/java/src/generated/java/io/cucumber/messages/types/TestRunFinished.java index 845c0f97..562ec42d 100644 --- a/java/src/generated/java/io/cucumber/messages/types/TestRunFinished.java +++ b/java/src/generated/java/io/cucumber/messages/types/TestRunFinished.java @@ -18,17 +18,20 @@ public final class TestRunFinished { private final Boolean success; private final Timestamp timestamp; private final Exception exception; + private final String testRunStartedId; public TestRunFinished( String message, Boolean success, Timestamp timestamp, - Exception exception + Exception exception, + String testRunStartedId ) { this.message = message; this.success = requireNonNull(success, "TestRunFinished.success cannot be null"); this.timestamp = requireNonNull(timestamp, "TestRunFinished.timestamp cannot be null"); this.exception = exception; + this.testRunStartedId = testRunStartedId; } /** @@ -59,6 +62,10 @@ public Optional getException() { return Optional.ofNullable(exception); } + public Optional getTestRunStartedId() { + return Optional.ofNullable(testRunStartedId); + } + @Override public boolean equals(Object o) { if (this == o) return true; @@ -68,7 +75,8 @@ public boolean equals(Object o) { Objects.equals(message, that.message) && success.equals(that.success) && timestamp.equals(that.timestamp) && - Objects.equals(exception, that.exception); + Objects.equals(exception, that.exception) && + Objects.equals(testRunStartedId, that.testRunStartedId); } @Override @@ -77,7 +85,8 @@ public int hashCode() { message, success, timestamp, - exception + exception, + testRunStartedId ); } @@ -88,6 +97,7 @@ public String toString() { ", success=" + success + ", timestamp=" + timestamp + ", exception=" + exception + + ", testRunStartedId=" + testRunStartedId + '}'; } } diff --git a/java/src/generated/java/io/cucumber/messages/types/TestRunStarted.java b/java/src/generated/java/io/cucumber/messages/types/TestRunStarted.java index 94be6c1a..bcf2f3a5 100644 --- a/java/src/generated/java/io/cucumber/messages/types/TestRunStarted.java +++ b/java/src/generated/java/io/cucumber/messages/types/TestRunStarted.java @@ -15,30 +15,39 @@ @SuppressWarnings("unused") public final class TestRunStarted { private final Timestamp timestamp; + private final String id; public TestRunStarted( - Timestamp timestamp + Timestamp timestamp, + String id ) { this.timestamp = requireNonNull(timestamp, "TestRunStarted.timestamp cannot be null"); + this.id = id; } public Timestamp getTimestamp() { return timestamp; } + public Optional getId() { + return Optional.ofNullable(id); + } + @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; TestRunStarted that = (TestRunStarted) o; return - timestamp.equals(that.timestamp); + timestamp.equals(that.timestamp) && + Objects.equals(id, that.id); } @Override public int hashCode() { return Objects.hash( - timestamp + timestamp, + id ); } @@ -46,6 +55,7 @@ public int hashCode() { public String toString() { return "TestRunStarted{" + "timestamp=" + timestamp + + ", id=" + id + '}'; } } diff --git a/javascript/src/messages.ts b/javascript/src/messages.ts index ceec6923..f61b5965 100644 --- a/javascript/src/messages.ts +++ b/javascript/src/messages.ts @@ -19,6 +19,8 @@ export class Attachment { testStepId?: string url?: string + + testRunStartedId?: string } export class Duration { @@ -78,6 +80,12 @@ export class Envelope { @Type(() => TestStepStarted) testStepStarted?: TestStepStarted + @Type(() => GlobalHookStarted) + globalHookStarted?: GlobalHookStarted + + @Type(() => GlobalHookFinished) + globalHookFinished?: GlobalHookFinished + @Type(() => UndefinedParameterType) undefinedParameterType?: UndefinedParameterType } @@ -304,6 +312,29 @@ export class Tag { id: string = '' } +export class GlobalHookFinished { + + testRunStartedId: string = '' + + hookId: string = '' + + @Type(() => TestStepResult) + result: TestStepResult = new TestStepResult() + + @Type(() => Timestamp) + timestamp: Timestamp = new Timestamp() +} + +export class GlobalHookStarted { + + testRunStartedId: string = '' + + hookId: string = '' + + @Type(() => Timestamp) + timestamp: Timestamp = new Timestamp() +} + export class Hook { id: string = '' @@ -537,6 +568,8 @@ export class TestCase { @Type(() => TestStep) testSteps: readonly TestStep[] = [] + + testRunStartedId?: string } export class Group { @@ -612,12 +645,16 @@ export class TestRunFinished { @Type(() => Exception) exception?: Exception + + testRunStartedId?: string } export class TestRunStarted { @Type(() => Timestamp) timestamp: Timestamp = new Timestamp() + + id?: string } export class TestStepFinished { diff --git a/messages.md b/messages.md index 8183c829..fad71a2e 100644 --- a/messages.md +++ b/messages.md @@ -15,6 +15,7 @@ will only have one of its fields set, which indicates the payload of the message | `testCaseStartedId` | string | no | | | `testStepId` | string | no | | | `url` | string | no | | +| `testRunStartedId` | string | no | | ## Duration @@ -43,6 +44,8 @@ will only have one of its fields set, which indicates the payload of the message | `testRunStarted` | [TestRunStarted](#testrunstarted) | no | | | `testStepFinished` | [TestStepFinished](#teststepfinished) | no | | | `testStepStarted` | [TestStepStarted](#teststepstarted) | no | | +| `globalHookStarted` | [GlobalHookStarted](#globalhookstarted) | no | | +| `globalHookFinished` | [GlobalHookFinished](#globalhookfinished) | no | | | `undefinedParameterType` | [UndefinedParameterType](#undefinedparametertype) | no | | ## Exception @@ -195,6 +198,23 @@ will only have one of its fields set, which indicates the payload of the message | `name` | string | yes | | | `id` | string | yes | | +## GlobalHookFinished + +| Field | Type | Required | Description | +| ----- | ---- | ----------- | ----------- | +| `testRunStartedId` | string | yes | | +| `hookId` | string | yes | | +| `result` | [TestStepResult](#teststepresult) | yes | | +| `timestamp` | [Timestamp](#timestamp) | yes | | + +## GlobalHookStarted + +| Field | Type | Required | Description | +| ----- | ---- | ----------- | ----------- | +| `testRunStartedId` | string | yes | | +| `hookId` | string | yes | | +| `timestamp` | [Timestamp](#timestamp) | yes | | + ## Hook | Field | Type | Required | Description | @@ -381,6 +401,7 @@ will only have one of its fields set, which indicates the payload of the message | `id` | string | yes | | | `pickleId` | string | yes | | | `testSteps` | [TestStep](#teststep)[] | yes | | +| `testRunStartedId` | string | no | | ## Group @@ -439,12 +460,14 @@ will only have one of its fields set, which indicates the payload of the message | `success` | boolean | yes | | | `timestamp` | [Timestamp](#timestamp) | yes | | | `exception` | [Exception](#exception) | no | | +| `testRunStartedId` | string | no | | ## TestRunStarted | Field | Type | Required | Description | | ----- | ---- | ----------- | ----------- | | `timestamp` | [Timestamp](#timestamp) | yes | | +| `id` | string | no | | ## TestStepFinished diff --git a/perl/lib/Cucumber/Messages.pm b/perl/lib/Cucumber/Messages.pm index 5e5d51e8..09694fd6 100644 --- a/perl/lib/Cucumber/Messages.pm +++ b/perl/lib/Cucumber/Messages.pm @@ -86,6 +86,7 @@ my %types = ( test_case_started_id => 'string', test_step_id => 'string', url => 'string', + test_run_started_id => 'string', ); # This is a work-around for the fact that Moo doesn't have introspection @@ -231,6 +232,16 @@ has url => ); +=head4 test_run_started_id + + +=cut + +has test_run_started_id => + (is => 'ro', + ); + + } package Cucumber::Messages::Duration { @@ -340,6 +351,8 @@ my %types = ( test_run_started => 'Cucumber::Messages::TestRunStarted', test_step_finished => 'Cucumber::Messages::TestStepFinished', test_step_started => 'Cucumber::Messages::TestStepStarted', + global_hook_started => 'Cucumber::Messages::GlobalHookStarted', + global_hook_finished => 'Cucumber::Messages::GlobalHookFinished', undefined_parameter_type => 'Cucumber::Messages::UndefinedParameterType', ); @@ -511,6 +524,26 @@ has test_step_started => ); +=head4 global_hook_started + + +=cut + +has global_hook_started => + (is => 'ro', + ); + + +=head4 global_hook_finished + + +=cut + +has global_hook_finished => + (is => 'ro', + ); + + =head4 undefined_parameter_type @@ -1999,6 +2032,167 @@ has id => ); +} + +package Cucumber::Messages::GlobalHookFinished { + +=head2 Cucumber::Messages::GlobalHookFinished + +=head3 DESCRIPTION + +Represents the GlobalHookFinished message in Cucumber's +L. + + + +=head3 ATTRIBUTES + +=cut + +use Moo; +extends 'Cucumber::Messages::Message'; + +use Scalar::Util qw( blessed ); + +my %types = ( + test_run_started_id => 'string', + hook_id => 'string', + result => 'Cucumber::Messages::TestStepResult', + timestamp => 'Cucumber::Messages::Timestamp', +); + +# This is a work-around for the fact that Moo doesn't have introspection +# and Perl doesn't have boolean values... +sub _types { + return \%types; +} + + + +=head4 test_run_started_id + +Identifier for the test run that this hook execution belongs to + +=cut + +has test_run_started_id => + (is => 'ro', + required => 1, + default => sub { '' }, + ); + + +=head4 hook_id + +Identifier for the hook that was executed + +=cut + +has hook_id => + (is => 'ro', + required => 1, + default => sub { '' }, + ); + + +=head4 result + + +=cut + +has result => + (is => 'ro', + required => 1, + default => sub { Cucumber::Messages::TestStepResult->new() }, + ); + + +=head4 timestamp + + +=cut + +has timestamp => + (is => 'ro', + required => 1, + default => sub { Cucumber::Messages::Timestamp->new() }, + ); + + +} + +package Cucumber::Messages::GlobalHookStarted { + +=head2 Cucumber::Messages::GlobalHookStarted + +=head3 DESCRIPTION + +Represents the GlobalHookStarted message in Cucumber's +L. + + + +=head3 ATTRIBUTES + +=cut + +use Moo; +extends 'Cucumber::Messages::Message'; + +use Scalar::Util qw( blessed ); + +my %types = ( + test_run_started_id => 'string', + hook_id => 'string', + timestamp => 'Cucumber::Messages::Timestamp', +); + +# This is a work-around for the fact that Moo doesn't have introspection +# and Perl doesn't have boolean values... +sub _types { + return \%types; +} + + + +=head4 test_run_started_id + +Identifier for the test run that this hook execution belongs to + +=cut + +has test_run_started_id => + (is => 'ro', + required => 1, + default => sub { '' }, + ); + + +=head4 hook_id + +Identifier for the hook that will be executed + +=cut + +has hook_id => + (is => 'ro', + required => 1, + default => sub { '' }, + ); + + +=head4 timestamp + + +=cut + +has timestamp => + (is => 'ro', + required => 1, + default => sub { Cucumber::Messages::Timestamp->new() }, + ); + + } package Cucumber::Messages::Hook { @@ -3729,6 +3923,7 @@ my %types = ( id => 'string', pickle_id => 'string', test_steps => '[]Cucumber::Messages::TestStep', + test_run_started_id => 'string', ); # This is a work-around for the fact that Moo doesn't have introspection @@ -3776,6 +3971,17 @@ has test_steps => ); +=head4 test_run_started_id + +Identifier for the test run that this case belongs to + +=cut + +has test_run_started_id => + (is => 'ro', + ); + + } package Cucumber::Messages::Group { @@ -4256,6 +4462,7 @@ my %types = ( success => 'boolean', timestamp => 'Cucumber::Messages::Timestamp', exception => 'Cucumber::Messages::Exception', + test_run_started_id => 'string', ); # This is a work-around for the fact that Moo doesn't have introspection @@ -4314,6 +4521,16 @@ has exception => ); +=head4 test_run_started_id + + +=cut + +has test_run_started_id => + (is => 'ro', + ); + + } package Cucumber::Messages::TestRunStarted { @@ -4338,6 +4555,7 @@ use Scalar::Util qw( blessed ); my %types = ( timestamp => 'Cucumber::Messages::Timestamp', + id => 'string', ); # This is a work-around for the fact that Moo doesn't have introspection @@ -4360,6 +4578,16 @@ has timestamp => ); +=head4 id + + +=cut + +has id => + (is => 'ro', + ); + + } package Cucumber::Messages::TestStepFinished { diff --git a/php/src-generated/Attachment.php b/php/src-generated/Attachment.php index 8bf48b2f..564f781d 100644 --- a/php/src-generated/Attachment.php +++ b/php/src-generated/Attachment.php @@ -85,6 +85,7 @@ public function __construct( * separately from reports. */ public readonly ?string $url = null, + public readonly ?string $testRunStartedId = null, ) { } @@ -103,6 +104,7 @@ public static function fromArray(array $arr): self self::ensureTestCaseStartedId($arr); self::ensureTestStepId($arr); self::ensureUrl($arr); + self::ensureTestRunStartedId($arr); return new self( (string) $arr['body'], @@ -113,6 +115,7 @@ public static function fromArray(array $arr): self isset($arr['testCaseStartedId']) ? (string) $arr['testCaseStartedId'] : null, isset($arr['testStepId']) ? (string) $arr['testStepId'] : null, isset($arr['url']) ? (string) $arr['url'] : null, + isset($arr['testRunStartedId']) ? (string) $arr['testRunStartedId'] : null, ); } @@ -204,4 +207,14 @@ private static function ensureUrl(array $arr): void throw new SchemaViolationException('Property \'url\' was array'); } } + + /** + * @psalm-assert array{testRunStartedId?: string|int|bool} $arr + */ + private static function ensureTestRunStartedId(array $arr): void + { + if (array_key_exists('testRunStartedId', $arr) && is_array($arr['testRunStartedId'])) { + throw new SchemaViolationException('Property \'testRunStartedId\' was array'); + } + } } diff --git a/php/src-generated/Envelope.php b/php/src-generated/Envelope.php index 589cdd59..00f4859c 100644 --- a/php/src-generated/Envelope.php +++ b/php/src-generated/Envelope.php @@ -46,6 +46,8 @@ public function __construct( public readonly ?TestRunStarted $testRunStarted = null, public readonly ?TestStepFinished $testStepFinished = null, public readonly ?TestStepStarted $testStepStarted = null, + public readonly ?GlobalHookStarted $globalHookStarted = null, + public readonly ?GlobalHookFinished $globalHookFinished = null, public readonly ?UndefinedParameterType $undefinedParameterType = null, ) { } @@ -73,6 +75,8 @@ public static function fromArray(array $arr): self self::ensureTestRunStarted($arr); self::ensureTestStepFinished($arr); self::ensureTestStepStarted($arr); + self::ensureGlobalHookStarted($arr); + self::ensureGlobalHookFinished($arr); self::ensureUndefinedParameterType($arr); return new self( @@ -92,6 +96,8 @@ public static function fromArray(array $arr): self isset($arr['testRunStarted']) ? TestRunStarted::fromArray($arr['testRunStarted']) : null, isset($arr['testStepFinished']) ? TestStepFinished::fromArray($arr['testStepFinished']) : null, isset($arr['testStepStarted']) ? TestStepStarted::fromArray($arr['testStepStarted']) : null, + isset($arr['globalHookStarted']) ? GlobalHookStarted::fromArray($arr['globalHookStarted']) : null, + isset($arr['globalHookFinished']) ? GlobalHookFinished::fromArray($arr['globalHookFinished']) : null, isset($arr['undefinedParameterType']) ? UndefinedParameterType::fromArray($arr['undefinedParameterType']) : null, ); } @@ -256,6 +262,26 @@ private static function ensureTestStepStarted(array $arr): void } } + /** + * @psalm-assert array{globalHookStarted?: array} $arr + */ + private static function ensureGlobalHookStarted(array $arr): void + { + if (array_key_exists('globalHookStarted', $arr) && !is_array($arr['globalHookStarted'])) { + throw new SchemaViolationException('Property \'globalHookStarted\' was not array'); + } + } + + /** + * @psalm-assert array{globalHookFinished?: array} $arr + */ + private static function ensureGlobalHookFinished(array $arr): void + { + if (array_key_exists('globalHookFinished', $arr) && !is_array($arr['globalHookFinished'])) { + throw new SchemaViolationException('Property \'globalHookFinished\' was not array'); + } + } + /** * @psalm-assert array{undefinedParameterType?: array} $arr */ diff --git a/php/src-generated/GlobalHookFinished.php b/php/src-generated/GlobalHookFinished.php new file mode 100644 index 00000000..4d7871f3 --- /dev/null +++ b/php/src-generated/GlobalHookFinished.php @@ -0,0 +1,114 @@ + TestStep::fromArray($member), $arr['testSteps'])), + isset($arr['testRunStartedId']) ? (string) $arr['testRunStartedId'] : null, ); } @@ -94,4 +101,14 @@ private static function ensureTestSteps(array $arr): void throw new SchemaViolationException('Property \'testSteps\' was not array'); } } + + /** + * @psalm-assert array{testRunStartedId?: string|int|bool} $arr + */ + private static function ensureTestRunStartedId(array $arr): void + { + if (array_key_exists('testRunStartedId', $arr) && is_array($arr['testRunStartedId'])) { + throw new SchemaViolationException('Property \'testRunStartedId\' was array'); + } + } } diff --git a/php/src-generated/TestRunFinished.php b/php/src-generated/TestRunFinished.php index 84eb02ad..70018b42 100644 --- a/php/src-generated/TestRunFinished.php +++ b/php/src-generated/TestRunFinished.php @@ -45,6 +45,7 @@ public function __construct( * Any exception thrown during the test run, if any. Does not include exceptions thrown while executing steps. */ public readonly ?Exception $exception = null, + public readonly ?string $testRunStartedId = null, ) { } @@ -59,12 +60,14 @@ public static function fromArray(array $arr): self self::ensureSuccess($arr); self::ensureTimestamp($arr); self::ensureException($arr); + self::ensureTestRunStartedId($arr); return new self( isset($arr['message']) ? (string) $arr['message'] : null, (bool) $arr['success'], Timestamp::fromArray($arr['timestamp']), isset($arr['exception']) ? Exception::fromArray($arr['exception']) : null, + isset($arr['testRunStartedId']) ? (string) $arr['testRunStartedId'] : null, ); } @@ -113,4 +116,14 @@ private static function ensureException(array $arr): void throw new SchemaViolationException('Property \'exception\' was not array'); } } + + /** + * @psalm-assert array{testRunStartedId?: string|int|bool} $arr + */ + private static function ensureTestRunStartedId(array $arr): void + { + if (array_key_exists('testRunStartedId', $arr) && is_array($arr['testRunStartedId'])) { + throw new SchemaViolationException('Property \'testRunStartedId\' was array'); + } + } } diff --git a/php/src-generated/TestRunStarted.php b/php/src-generated/TestRunStarted.php index 121c1d4f..92d1bd1c 100644 --- a/php/src-generated/TestRunStarted.php +++ b/php/src-generated/TestRunStarted.php @@ -26,6 +26,7 @@ final class TestRunStarted implements JsonSerializable */ public function __construct( public readonly Timestamp $timestamp = new Timestamp(), + public readonly ?string $id = null, ) { } @@ -37,9 +38,11 @@ public function __construct( public static function fromArray(array $arr): self { self::ensureTimestamp($arr); + self::ensureId($arr); return new self( Timestamp::fromArray($arr['timestamp']), + isset($arr['id']) ? (string) $arr['id'] : null, ); } @@ -55,4 +58,14 @@ private static function ensureTimestamp(array $arr): void throw new SchemaViolationException('Property \'timestamp\' was not array'); } } + + /** + * @psalm-assert array{id?: string|int|bool} $arr + */ + private static function ensureId(array $arr): void + { + if (array_key_exists('id', $arr) && is_array($arr['id'])) { + throw new SchemaViolationException('Property \'id\' was array'); + } + } } diff --git a/ruby/lib/cucumber/messages/attachment.rb b/ruby/lib/cucumber/messages/attachment.rb index fae7a75c..df4aebcd 100644 --- a/ruby/lib/cucumber/messages/attachment.rb +++ b/ruby/lib/cucumber/messages/attachment.rb @@ -79,6 +79,8 @@ class Attachment < Message ## attr_reader :url + attr_reader :test_run_started_id + def initialize( body: '', content_encoding: AttachmentContentEncoding::IDENTITY, @@ -87,7 +89,8 @@ def initialize( source: nil, test_case_started_id: nil, test_step_id: nil, - url: nil + url: nil, + test_run_started_id: nil ) @body = body @content_encoding = content_encoding @@ -97,6 +100,7 @@ def initialize( @test_case_started_id = test_case_started_id @test_step_id = test_step_id @url = url + @test_run_started_id = test_run_started_id super() end @@ -118,7 +122,8 @@ def self.from_h(hash) source: Source.from_h(hash[:source]), test_case_started_id: hash[:testCaseStartedId], test_step_id: hash[:testStepId], - url: hash[:url] + url: hash[:url], + test_run_started_id: hash[:testRunStartedId] ) end end diff --git a/ruby/lib/cucumber/messages/envelope.rb b/ruby/lib/cucumber/messages/envelope.rb index 1cc84706..14091e84 100644 --- a/ruby/lib/cucumber/messages/envelope.rb +++ b/ruby/lib/cucumber/messages/envelope.rb @@ -48,6 +48,10 @@ class Envelope < Message attr_reader :test_step_started + attr_reader :global_hook_started + + attr_reader :global_hook_finished + attr_reader :undefined_parameter_type def initialize( @@ -67,6 +71,8 @@ def initialize( test_run_started: nil, test_step_finished: nil, test_step_started: nil, + global_hook_started: nil, + global_hook_finished: nil, undefined_parameter_type: nil ) @attachment = attachment @@ -85,6 +91,8 @@ def initialize( @test_run_started = test_run_started @test_step_finished = test_step_finished @test_step_started = test_step_started + @global_hook_started = global_hook_started + @global_hook_finished = global_hook_finished @undefined_parameter_type = undefined_parameter_type super() end @@ -116,6 +124,8 @@ def self.from_h(hash) test_run_started: TestRunStarted.from_h(hash[:testRunStarted]), test_step_finished: TestStepFinished.from_h(hash[:testStepFinished]), test_step_started: TestStepStarted.from_h(hash[:testStepStarted]), + global_hook_started: GlobalHookStarted.from_h(hash[:globalHookStarted]), + global_hook_finished: GlobalHookFinished.from_h(hash[:globalHookFinished]), undefined_parameter_type: UndefinedParameterType.from_h(hash[:undefinedParameterType]) ) end diff --git a/ruby/lib/cucumber/messages/global_hook_finished.rb b/ruby/lib/cucumber/messages/global_hook_finished.rb new file mode 100644 index 00000000..9b189a04 --- /dev/null +++ b/ruby/lib/cucumber/messages/global_hook_finished.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true + +# The code was auto-generated by {this script}[https://github.com/cucumber/messages/blob/main/jsonschema/scripts/codegen.rb] +module Cucumber + module Messages + ## + # Represents the GlobalHookFinished message in Cucumber's {message protocol}[https://github.com/cucumber/messages]. + ## + ## + class GlobalHookFinished < Message + ## + # Identifier for the test run that this hook execution belongs to + ## + attr_reader :test_run_started_id + + ## + # Identifier for the hook that was executed + ## + attr_reader :hook_id + + attr_reader :result + + attr_reader :timestamp + + def initialize( + test_run_started_id: '', + hook_id: '', + result: TestStepResult.new, + timestamp: Timestamp.new + ) + @test_run_started_id = test_run_started_id + @hook_id = hook_id + @result = result + @timestamp = timestamp + super() + end + + ## + # Returns a new GlobalHookFinished from the given hash. + # If the hash keys are camelCased, they are properly assigned to the + # corresponding snake_cased attributes. + # + # Cucumber::Messages::GlobalHookFinished.from_h(some_hash) # => # + ## + def self.from_h(hash) + return nil if hash.nil? + + new( + test_run_started_id: hash[:testRunStartedId], + hook_id: hash[:hookId], + result: TestStepResult.from_h(hash[:result]), + timestamp: Timestamp.from_h(hash[:timestamp]) + ) + end + end + end +end diff --git a/ruby/lib/cucumber/messages/global_hook_started.rb b/ruby/lib/cucumber/messages/global_hook_started.rb new file mode 100644 index 00000000..bd4bc765 --- /dev/null +++ b/ruby/lib/cucumber/messages/global_hook_started.rb @@ -0,0 +1,52 @@ +# frozen_string_literal: true + +# The code was auto-generated by {this script}[https://github.com/cucumber/messages/blob/main/jsonschema/scripts/codegen.rb] +module Cucumber + module Messages + ## + # Represents the GlobalHookStarted message in Cucumber's {message protocol}[https://github.com/cucumber/messages]. + ## + ## + class GlobalHookStarted < Message + ## + # Identifier for the test run that this hook execution belongs to + ## + attr_reader :test_run_started_id + + ## + # Identifier for the hook that will be executed + ## + attr_reader :hook_id + + attr_reader :timestamp + + def initialize( + test_run_started_id: '', + hook_id: '', + timestamp: Timestamp.new + ) + @test_run_started_id = test_run_started_id + @hook_id = hook_id + @timestamp = timestamp + super() + end + + ## + # Returns a new GlobalHookStarted from the given hash. + # If the hash keys are camelCased, they are properly assigned to the + # corresponding snake_cased attributes. + # + # Cucumber::Messages::GlobalHookStarted.from_h(some_hash) # => # + ## + def self.from_h(hash) + return nil if hash.nil? + + new( + test_run_started_id: hash[:testRunStartedId], + hook_id: hash[:hookId], + timestamp: Timestamp.from_h(hash[:timestamp]) + ) + end + end + end +end diff --git a/ruby/lib/cucumber/messages/test_case.rb b/ruby/lib/cucumber/messages/test_case.rb index d4204735..5398d09d 100644 --- a/ruby/lib/cucumber/messages/test_case.rb +++ b/ruby/lib/cucumber/messages/test_case.rb @@ -22,14 +22,21 @@ class TestCase < Message attr_reader :test_steps + ## + # Identifier for the test run that this case belongs to + ## + attr_reader :test_run_started_id + def initialize( id: '', pickle_id: '', - test_steps: [] + test_steps: [], + test_run_started_id: nil ) @id = id @pickle_id = pickle_id @test_steps = test_steps + @test_run_started_id = test_run_started_id super() end @@ -46,7 +53,8 @@ def self.from_h(hash) new( id: hash[:id], pickle_id: hash[:pickleId], - test_steps: hash[:testSteps]&.map { |item| TestStep.from_h(item) } + test_steps: hash[:testSteps]&.map { |item| TestStep.from_h(item) }, + test_run_started_id: hash[:testRunStartedId] ) end end diff --git a/ruby/lib/cucumber/messages/test_run_finished.rb b/ruby/lib/cucumber/messages/test_run_finished.rb index 6374d4fb..ac6eaffa 100644 --- a/ruby/lib/cucumber/messages/test_run_finished.rb +++ b/ruby/lib/cucumber/messages/test_run_finished.rb @@ -28,16 +28,20 @@ class TestRunFinished < Message ## attr_reader :exception + attr_reader :test_run_started_id + def initialize( message: nil, success: false, timestamp: Timestamp.new, - exception: nil + exception: nil, + test_run_started_id: nil ) @message = message @success = success @timestamp = timestamp @exception = exception + @test_run_started_id = test_run_started_id super() end @@ -55,7 +59,8 @@ def self.from_h(hash) message: hash[:message], success: hash[:success], timestamp: Timestamp.from_h(hash[:timestamp]), - exception: Exception.from_h(hash[:exception]) + exception: Exception.from_h(hash[:exception]), + test_run_started_id: hash[:testRunStartedId] ) end end diff --git a/ruby/lib/cucumber/messages/test_run_started.rb b/ruby/lib/cucumber/messages/test_run_started.rb index dea6be01..fff1581f 100644 --- a/ruby/lib/cucumber/messages/test_run_started.rb +++ b/ruby/lib/cucumber/messages/test_run_started.rb @@ -10,10 +10,14 @@ module Messages class TestRunStarted < Message attr_reader :timestamp + attr_reader :id + def initialize( - timestamp: Timestamp.new + timestamp: Timestamp.new, + id: nil ) @timestamp = timestamp + @id = id super() end @@ -28,7 +32,8 @@ def self.from_h(hash) return nil if hash.nil? new( - timestamp: Timestamp.from_h(hash[:timestamp]) + timestamp: Timestamp.from_h(hash[:timestamp]), + id: hash[:id] ) end end From 127809bed9f39993d8af1123b719323b604fe487 Mon Sep 17 00:00:00 2001 From: David Goss Date: Fri, 2 Aug 2024 21:21:18 -0400 Subject: [PATCH 04/18] fix the java tests --- .../io/cucumber/messages/JacksonTest.java | 4 +++- .../io/cucumber/messages/MessagesTest.java | 4 +++- .../messages/NdjsonSerializationTest.java | 21 ++++++------------- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/java/src/test/java/io/cucumber/messages/JacksonTest.java b/java/src/test/java/io/cucumber/messages/JacksonTest.java index d2b86d17..a8fc6f73 100644 --- a/java/src/test/java/io/cucumber/messages/JacksonTest.java +++ b/java/src/test/java/io/cucumber/messages/JacksonTest.java @@ -7,6 +7,8 @@ import io.cucumber.messages.types.Timestamp; import org.junit.jupiter.api.Test; +import java.util.UUID; + import static io.cucumber.messages.Jackson.OBJECT_MAPPER; import static io.cucumber.messages.types.SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -27,7 +29,7 @@ void serialize_enums_using_value() throws JsonProcessingException { @Test void can_deserialize_envelope() throws JsonProcessingException { - Envelope source = Envelope.of(new TestRunStarted(new Timestamp(3L, 14L))); + Envelope source = Envelope.of(new TestRunStarted(new Timestamp(3L, 14L), UUID.randomUUID().toString())); String json = OBJECT_MAPPER.writeValueAsString(source); assertEquals(source, OBJECT_MAPPER.readValue(json, Envelope.class)); } diff --git a/java/src/test/java/io/cucumber/messages/MessagesTest.java b/java/src/test/java/io/cucumber/messages/MessagesTest.java index 840037b9..4d7e3556 100644 --- a/java/src/test/java/io/cucumber/messages/MessagesTest.java +++ b/java/src/test/java/io/cucumber/messages/MessagesTest.java @@ -10,7 +10,7 @@ public class MessagesTest { @Test void is_invalid_when_required_fields_are_missing() { assertThrows(NullPointerException.class, () -> { - new Attachment(null, null, null, null, null, null, null, null); + new Attachment(null, null, null, null, null, null, null, null, null); }, "Attachment.body cannot be null"); } @@ -33,6 +33,8 @@ void is_valid_when_no_required_fields_are_missing() { null, null, null, + null, + null, null ); } diff --git a/java/src/test/java/io/cucumber/messages/NdjsonSerializationTest.java b/java/src/test/java/io/cucumber/messages/NdjsonSerializationTest.java index 1c05a2cc..b9185aa9 100644 --- a/java/src/test/java/io/cucumber/messages/NdjsonSerializationTest.java +++ b/java/src/test/java/io/cucumber/messages/NdjsonSerializationTest.java @@ -4,8 +4,6 @@ import io.cucumber.messages.types.Envelope; import io.cucumber.messages.types.Source; import io.cucumber.messages.types.SourceMediaType; -import io.cucumber.messages.types.TestRunStarted; -import io.cucumber.messages.types.Timestamp; import org.junit.jupiter.api.Test; import java.io.ByteArrayInputStream; @@ -64,6 +62,8 @@ void does_not_serialize_null_fields() throws IOException { null, null, null, + null, + null, null )); writer.flush(); @@ -94,6 +94,8 @@ void ignores_missing_fields() { null, null, null, + null, + null, null ), envelope); assertFalse(iterator.hasNext()); @@ -124,6 +126,8 @@ void ignores_empty_lines() { null, null, null, + null, + null, null ), envelope); } @@ -143,19 +147,6 @@ void handles_enums() { assertFalse(iterator.hasNext()); } - @Test - void handles_single_argument_constructors() { - InputStream input = new ByteArrayInputStream( - "{\"testRunStarted\": {\"timestamp\":{\"nanos\":0,\"seconds\":0}}}\n".getBytes(UTF_8)); - Iterable incomingMessages = createMessageIterable(input); - Iterator iterator = incomingMessages.iterator(); - assertTrue(iterator.hasNext()); - Envelope testRunStarted = iterator.next(); - Envelope expected = Envelope.of(new TestRunStarted(new Timestamp(0L, 0L))); - assertEquals(expected, testRunStarted); - assertFalse(iterator.hasNext()); - } - @Test void includes_offending_line_in_error_message() { InputStream input = new ByteArrayInputStream("BLA BLA".getBytes(UTF_8)); From 1222bd8b1ca0e2670f2b7eef48a1907505f8d3b4 Mon Sep 17 00:00:00 2001 From: David Goss Date: Sun, 4 Aug 2024 07:58:51 -0400 Subject: [PATCH 05/18] fix: update dotnet ctor --- .../Cucumber.Messages.Specs/BasicMessageSerializationTests.cs | 2 +- dotnet/Cucumber.Messages.Specs/MessagesTest.cs | 2 +- .../Cucumber.Messages.Specs/NdjsonStreamSerializationTests.cs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dotnet/Cucumber.Messages.Specs/BasicMessageSerializationTests.cs b/dotnet/Cucumber.Messages.Specs/BasicMessageSerializationTests.cs index af4006c0..db54c8b8 100644 --- a/dotnet/Cucumber.Messages.Specs/BasicMessageSerializationTests.cs +++ b/dotnet/Cucumber.Messages.Specs/BasicMessageSerializationTests.cs @@ -23,7 +23,7 @@ public void SerializesAnEnvelopeToNDJSONCorrectly() null, null, new Location(3, null)); var stepDefPattern = new StepDefinitionPattern("I have {int} cukes in my belly", StepDefinitionPatternType.CUCUMBER_EXPRESSION); var stepDefinition = new StepDefinition("0", stepDefPattern, sourceReference); - var env = new Envelope(null, null, null, null, null, null, null, null, stepDefinition, null, null, null, null, null, null, null, null); + var env = new Envelope(null, null, null, null, null, null, null, null, stepDefinition, null, null, null, null, null, null, null, null, null, null); var serializedStepDefinition = NdjsonSerializer.Serialize(env); var reconstructedStepDefinition = NdjsonSerializer.Deserialize(serializedStepDefinition); diff --git a/dotnet/Cucumber.Messages.Specs/MessagesTest.cs b/dotnet/Cucumber.Messages.Specs/MessagesTest.cs index eeb4e64a..88d4d5f0 100644 --- a/dotnet/Cucumber.Messages.Specs/MessagesTest.cs +++ b/dotnet/Cucumber.Messages.Specs/MessagesTest.cs @@ -21,7 +21,7 @@ public void ThrowsWhenRequiredFieldsAreMissing() public void IsValidWhenNoRequiredFieldsAreMissing() { // This should succeed as no constructor arguments to an Envelope are required. - var env = new Envelope(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null); + var env = new Envelope(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null); } } } diff --git a/dotnet/Cucumber.Messages.Specs/NdjsonStreamSerializationTests.cs b/dotnet/Cucumber.Messages.Specs/NdjsonStreamSerializationTests.cs index 4b9c882a..285b1d38 100644 --- a/dotnet/Cucumber.Messages.Specs/NdjsonStreamSerializationTests.cs +++ b/dotnet/Cucumber.Messages.Specs/NdjsonStreamSerializationTests.cs @@ -30,7 +30,7 @@ public void DoesNotSerializeNullFields() { MemoryStream memoryStream = new MemoryStream(); var writer = new MessageToNdjsonWriter(memoryStream); - writer.Write(new Envelope(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null)); + writer.Write(new Envelope(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null)); var json = Encoding.UTF8.GetString(memoryStream.ToArray()); Assert.Equal("{}"+Environment.NewLine, json); @@ -42,7 +42,7 @@ public void IgnoresEmptyLines() MemoryStream memoryStream = new MemoryStream(Encoding.UTF8.GetBytes("{}\n{}\n\n{}\n")); var enumerator = new NdjsonMessageReader(memoryStream).GetEnumerator(); - var expectedEnvelope = new Envelope(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null); + var expectedEnvelope = new Envelope(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null); for (int i = 0; i < 3; i++) { Assert.True(enumerator.MoveNext()); From f1c5520f1a0ed61697c0302c5c50c162369f63d5 Mon Sep 17 00:00:00 2001 From: David Goss Date: Sun, 4 Aug 2024 08:04:13 -0400 Subject: [PATCH 06/18] fix: update dotnet ctor --- .../Cucumber.Messages.Specs/NdjsonStreamSerializationTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dotnet/Cucumber.Messages.Specs/NdjsonStreamSerializationTests.cs b/dotnet/Cucumber.Messages.Specs/NdjsonStreamSerializationTests.cs index e49e302c..a3234dc6 100644 --- a/dotnet/Cucumber.Messages.Specs/NdjsonStreamSerializationTests.cs +++ b/dotnet/Cucumber.Messages.Specs/NdjsonStreamSerializationTests.cs @@ -73,7 +73,7 @@ public void Handles_Single_Argument_Constructor() var enumerator = new NdjsonMessageReaderSUT(memoryStream).GetEnumerator(); Assert.True(enumerator.MoveNext()); Envelope envelope = enumerator.Current; - Envelope expected = Envelope.Create(new TestRunStarted(new Timestamp(0, 0))); + Envelope expected = Envelope.Create(new TestRunStarted(new Timestamp(0, 0), "id")); Assert.Equal(expected, envelope); Assert.False(enumerator.MoveNext()); From d19c1f8863a6249c95203e18963912b2e30db6c6 Mon Sep 17 00:00:00 2001 From: David Goss Date: Sun, 4 Aug 2024 08:04:40 -0400 Subject: [PATCH 07/18] fix: remove defunct test --- .../NdjsonStreamSerializationTests.cs | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/dotnet/Cucumber.Messages.Specs/NdjsonStreamSerializationTests.cs b/dotnet/Cucumber.Messages.Specs/NdjsonStreamSerializationTests.cs index a3234dc6..3c763579 100644 --- a/dotnet/Cucumber.Messages.Specs/NdjsonStreamSerializationTests.cs +++ b/dotnet/Cucumber.Messages.Specs/NdjsonStreamSerializationTests.cs @@ -66,19 +66,6 @@ public void Handles_Enums() Assert.False(enumerator.MoveNext()); } - [Fact] - public void Handles_Single_Argument_Constructor() - { - MemoryStream memoryStream = new MemoryStream(Encoding.UTF8.GetBytes("{\"testRunStarted\": {\"timestamp\":{\"nanos\":0,\"seconds\":0}}}\n")); - var enumerator = new NdjsonMessageReaderSUT(memoryStream).GetEnumerator(); - Assert.True(enumerator.MoveNext()); - Envelope envelope = enumerator.Current; - Envelope expected = Envelope.Create(new TestRunStarted(new Timestamp(0, 0), "id")); - - Assert.Equal(expected, envelope); - Assert.False(enumerator.MoveNext()); - } - [Fact] public void Includes_Offending_Line_In_Error_Message() { From a3bc6bdc4fc4cb0bcb62f87dce3f4ff16f2d0503 Mon Sep 17 00:00:00 2001 From: David Goss Date: Thu, 22 Aug 2024 07:57:52 +0100 Subject: [PATCH 08/18] chore: regenerate code for comments --- perl/lib/Cucumber/Messages.pm | 5 ----- php/src-generated/GlobalHookFinished.php | 2 +- php/src-generated/GlobalHookStarted.php | 2 +- ruby/lib/cucumber/messages/global_hook_finished.rb | 2 +- ruby/lib/cucumber/messages/global_hook_started.rb | 2 +- 5 files changed, 4 insertions(+), 9 deletions(-) diff --git a/perl/lib/Cucumber/Messages.pm b/perl/lib/Cucumber/Messages.pm index b54d8823..f79dfd64 100644 --- a/perl/lib/Cucumber/Messages.pm +++ b/perl/lib/Cucumber/Messages.pm @@ -2036,7 +2036,6 @@ sub _types { =head4 test_run_started_id Identifier for the test run that this hook execution belongs to - =cut has test_run_started_id => @@ -2049,7 +2048,6 @@ has test_run_started_id => =head4 hook_id Identifier for the hook that was executed - =cut has hook_id => @@ -2122,7 +2120,6 @@ sub _types { =head4 test_run_started_id Identifier for the test run that this hook execution belongs to - =cut has test_run_started_id => @@ -2135,7 +2132,6 @@ has test_run_started_id => =head4 hook_id Identifier for the hook that will be executed - =cut has hook_id => @@ -3912,7 +3908,6 @@ has test_steps => =head4 test_run_started_id Identifier for the test run that this case belongs to - =cut has test_run_started_id => diff --git a/php/src-generated/GlobalHookFinished.php b/php/src-generated/GlobalHookFinished.php index 4d7871f3..00524200 100644 --- a/php/src-generated/GlobalHookFinished.php +++ b/php/src-generated/GlobalHookFinished.php @@ -3,7 +3,7 @@ declare(strict_types=1); /** - * This code was auto-generated by {this script}[https://github.com/cucumber/messages/blob/main/jsonschema/scripts/codegen.rb] + * This code was auto-generated by {this script}[https://github.com/cucumber/messages/blob/main/codegen/codegen.rb] */ namespace Cucumber\Messages; diff --git a/php/src-generated/GlobalHookStarted.php b/php/src-generated/GlobalHookStarted.php index d7894fc5..d13e112c 100644 --- a/php/src-generated/GlobalHookStarted.php +++ b/php/src-generated/GlobalHookStarted.php @@ -3,7 +3,7 @@ declare(strict_types=1); /** - * This code was auto-generated by {this script}[https://github.com/cucumber/messages/blob/main/jsonschema/scripts/codegen.rb] + * This code was auto-generated by {this script}[https://github.com/cucumber/messages/blob/main/codegen/codegen.rb] */ namespace Cucumber\Messages; diff --git a/ruby/lib/cucumber/messages/global_hook_finished.rb b/ruby/lib/cucumber/messages/global_hook_finished.rb index 9b189a04..15e74fdc 100644 --- a/ruby/lib/cucumber/messages/global_hook_finished.rb +++ b/ruby/lib/cucumber/messages/global_hook_finished.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -# The code was auto-generated by {this script}[https://github.com/cucumber/messages/blob/main/jsonschema/scripts/codegen.rb] +# The code was auto-generated by {this script}[https://github.com/cucumber/messages/blob/main/codegen/codegen.rb] module Cucumber module Messages ## diff --git a/ruby/lib/cucumber/messages/global_hook_started.rb b/ruby/lib/cucumber/messages/global_hook_started.rb index bd4bc765..62577ff4 100644 --- a/ruby/lib/cucumber/messages/global_hook_started.rb +++ b/ruby/lib/cucumber/messages/global_hook_started.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -# The code was auto-generated by {this script}[https://github.com/cucumber/messages/blob/main/jsonschema/scripts/codegen.rb] +# The code was auto-generated by {this script}[https://github.com/cucumber/messages/blob/main/codegen/codegen.rb] module Cucumber module Messages ## From 4228da456aaa3e2a78fa9aa205cefb781261aaa3 Mon Sep 17 00:00:00 2001 From: David Goss Date: Thu, 22 Aug 2024 08:06:45 +0100 Subject: [PATCH 09/18] add unique identifier per hook run --- .../messages/global_hook_finished.hpp | 3 +- .../cucumber/messages/global_hook_started.hpp | 1 + .../messages/global_hook_finished.cpp | 6 +-- .../cucumber/messages/global_hook_started.cpp | 4 +- .../generated/GlobalHookFinished.cs | 29 +++++--------- .../generated/GlobalHookStarted.cs | 13 +++++- go/messages.go | 8 ++-- .../messages/types/GlobalHookFinished.java | 31 +++++--------- .../messages/types/GlobalHookStarted.java | 15 ++++++- javascript/src/messages.ts | 6 +-- jsonschema/GlobalHookFinished.json | 11 ++--- jsonschema/GlobalHookStarted.json | 5 +++ messages.md | 4 +- perl/lib/Cucumber/Messages.pm | 34 ++++++++-------- php/src-generated/GlobalHookFinished.php | 40 +++++-------------- php/src-generated/GlobalHookStarted.php | 20 ++++++++++ .../cucumber/messages/global_hook_finished.rb | 18 +++------ .../cucumber/messages/global_hook_started.rb | 8 ++++ 18 files changed, 128 insertions(+), 128 deletions(-) diff --git a/cpp/include/messages/cucumber/messages/global_hook_finished.hpp b/cpp/include/messages/cucumber/messages/global_hook_finished.hpp index b298d620..d87d952c 100644 --- a/cpp/include/messages/cucumber/messages/global_hook_finished.hpp +++ b/cpp/include/messages/cucumber/messages/global_hook_finished.hpp @@ -21,8 +21,7 @@ using json = nlohmann::json; struct global_hook_finished { - std::string test_run_started_id; - std::string hook_id; + std::string global_hook_started_id; cucumber::messages::test_step_result result; cucumber::messages::timestamp timestamp; diff --git a/cpp/include/messages/cucumber/messages/global_hook_started.hpp b/cpp/include/messages/cucumber/messages/global_hook_started.hpp index 5442c80d..bea25c77 100644 --- a/cpp/include/messages/cucumber/messages/global_hook_started.hpp +++ b/cpp/include/messages/cucumber/messages/global_hook_started.hpp @@ -20,6 +20,7 @@ using json = nlohmann::json; struct global_hook_started { + std::string id; std::string test_run_started_id; std::string hook_id; cucumber::messages::timestamp timestamp; diff --git a/cpp/src/lib/messages/cucumber/messages/global_hook_finished.cpp b/cpp/src/lib/messages/cucumber/messages/global_hook_finished.cpp index b7abbc43..5fd77aba 100644 --- a/cpp/src/lib/messages/cucumber/messages/global_hook_finished.cpp +++ b/cpp/src/lib/messages/cucumber/messages/global_hook_finished.cpp @@ -10,8 +10,7 @@ global_hook_finished::to_string() const { std::ostringstream oss; - cucumber::messages::to_string(oss, "test_run_started_id=", test_run_started_id); - cucumber::messages::to_string(oss, ", hook_id=", hook_id); + cucumber::messages::to_string(oss, "global_hook_started_id=", global_hook_started_id); cucumber::messages::to_string(oss, ", result=", result); cucumber::messages::to_string(oss, ", timestamp=", timestamp); @@ -21,8 +20,7 @@ global_hook_finished::to_string() const void global_hook_finished::to_json(json& j) const { - cucumber::messages::to_json(j, camelize("test_run_started_id"), test_run_started_id); - cucumber::messages::to_json(j, camelize("hook_id"), hook_id); + cucumber::messages::to_json(j, camelize("global_hook_started_id"), global_hook_started_id); cucumber::messages::to_json(j, camelize("result"), result); cucumber::messages::to_json(j, camelize("timestamp"), timestamp); } diff --git a/cpp/src/lib/messages/cucumber/messages/global_hook_started.cpp b/cpp/src/lib/messages/cucumber/messages/global_hook_started.cpp index bdf3dac2..bb5a734d 100644 --- a/cpp/src/lib/messages/cucumber/messages/global_hook_started.cpp +++ b/cpp/src/lib/messages/cucumber/messages/global_hook_started.cpp @@ -10,7 +10,8 @@ global_hook_started::to_string() const { std::ostringstream oss; - cucumber::messages::to_string(oss, "test_run_started_id=", test_run_started_id); + cucumber::messages::to_string(oss, "id=", id); + cucumber::messages::to_string(oss, ", test_run_started_id=", test_run_started_id); cucumber::messages::to_string(oss, ", hook_id=", hook_id); cucumber::messages::to_string(oss, ", timestamp=", timestamp); @@ -20,6 +21,7 @@ global_hook_started::to_string() const void global_hook_started::to_json(json& j) const { + cucumber::messages::to_json(j, camelize("id"), id); cucumber::messages::to_json(j, camelize("test_run_started_id"), test_run_started_id); cucumber::messages::to_json(j, camelize("hook_id"), hook_id); cucumber::messages::to_json(j, camelize("timestamp"), timestamp); diff --git a/dotnet/Cucumber.Messages/generated/GlobalHookFinished.cs b/dotnet/Cucumber.Messages/generated/GlobalHookFinished.cs index f4433604..d850eb20 100644 --- a/dotnet/Cucumber.Messages/generated/GlobalHookFinished.cs +++ b/dotnet/Cucumber.Messages/generated/GlobalHookFinished.cs @@ -17,28 +17,21 @@ namespace Io.Cucumber.Messages.Types; public sealed class GlobalHookFinished { /** - * Identifier for the test run that this hook execution belongs to + * Identifier for the hook execution that has finished */ - public string TestRunStartedId { get; private set; } - /** - * Identifier for the hook that was executed - */ - public string HookId { get; private set; } + public string GlobalHookStartedId { get; private set; } public TestStepResult Result { get; private set; } public Timestamp Timestamp { get; private set; } public GlobalHookFinished( - string testRunStartedId, - string hookId, + string globalHookStartedId, TestStepResult result, Timestamp timestamp ) { - RequireNonNull(testRunStartedId, "TestRunStartedId", "GlobalHookFinished.TestRunStartedId cannot be null"); - this.TestRunStartedId = testRunStartedId; - RequireNonNull(hookId, "HookId", "GlobalHookFinished.HookId cannot be null"); - this.HookId = hookId; + RequireNonNull(globalHookStartedId, "GlobalHookStartedId", "GlobalHookFinished.GlobalHookStartedId cannot be null"); + this.GlobalHookStartedId = globalHookStartedId; RequireNonNull(result, "Result", "GlobalHookFinished.Result cannot be null"); this.Result = result; RequireNonNull(timestamp, "Timestamp", "GlobalHookFinished.Timestamp cannot be null"); @@ -51,8 +44,7 @@ public override bool Equals(Object o) if (o == null || this.GetType() != o.GetType()) return false; GlobalHookFinished that = (GlobalHookFinished) o; return - TestRunStartedId.Equals(that.TestRunStartedId) && - HookId.Equals(that.HookId) && + GlobalHookStartedId.Equals(that.GlobalHookStartedId) && Result.Equals(that.Result) && Timestamp.Equals(that.Timestamp); } @@ -60,10 +52,8 @@ public override bool Equals(Object o) public override int GetHashCode() { int hash = 17; - if (TestRunStartedId != null) - hash = hash * 31 + TestRunStartedId.GetHashCode(); - if (HookId != null) - hash = hash * 31 + HookId.GetHashCode(); + if (GlobalHookStartedId != null) + hash = hash * 31 + GlobalHookStartedId.GetHashCode(); if (Result != null) hash = hash * 31 + Result.GetHashCode(); if (Timestamp != null) @@ -74,8 +64,7 @@ public override int GetHashCode() public override string ToString() { return "GlobalHookFinished{" + - "testRunStartedId=" + TestRunStartedId + - ", hookId=" + HookId + + "globalHookStartedId=" + GlobalHookStartedId + ", result=" + Result + ", timestamp=" + Timestamp + '}'; diff --git a/dotnet/Cucumber.Messages/generated/GlobalHookStarted.cs b/dotnet/Cucumber.Messages/generated/GlobalHookStarted.cs index 0e5cca1b..ce7a33a6 100644 --- a/dotnet/Cucumber.Messages/generated/GlobalHookStarted.cs +++ b/dotnet/Cucumber.Messages/generated/GlobalHookStarted.cs @@ -16,6 +16,10 @@ namespace Io.Cucumber.Messages.Types; public sealed class GlobalHookStarted { + /** + * Unique identifier for this hook execution + */ + public string Id { get; private set; } /** * Identifier for the test run that this hook execution belongs to */ @@ -28,11 +32,14 @@ public sealed class GlobalHookStarted public GlobalHookStarted( + string id, string testRunStartedId, string hookId, Timestamp timestamp ) { + RequireNonNull(id, "Id", "GlobalHookStarted.Id cannot be null"); + this.Id = id; RequireNonNull(testRunStartedId, "TestRunStartedId", "GlobalHookStarted.TestRunStartedId cannot be null"); this.TestRunStartedId = testRunStartedId; RequireNonNull(hookId, "HookId", "GlobalHookStarted.HookId cannot be null"); @@ -47,6 +54,7 @@ public override bool Equals(Object o) if (o == null || this.GetType() != o.GetType()) return false; GlobalHookStarted that = (GlobalHookStarted) o; return + Id.Equals(that.Id) && TestRunStartedId.Equals(that.TestRunStartedId) && HookId.Equals(that.HookId) && Timestamp.Equals(that.Timestamp); @@ -55,6 +63,8 @@ public override bool Equals(Object o) public override int GetHashCode() { int hash = 17; + if (Id != null) + hash = hash * 31 + Id.GetHashCode(); if (TestRunStartedId != null) hash = hash * 31 + TestRunStartedId.GetHashCode(); if (HookId != null) @@ -67,7 +77,8 @@ public override int GetHashCode() public override string ToString() { return "GlobalHookStarted{" + - "testRunStartedId=" + TestRunStartedId + + "id=" + Id + + ", testRunStartedId=" + TestRunStartedId + ", hookId=" + HookId + ", timestamp=" + Timestamp + '}'; diff --git a/go/messages.go b/go/messages.go index 3e9270e3..0322c670 100644 --- a/go/messages.go +++ b/go/messages.go @@ -158,13 +158,13 @@ type Tag struct { } type GlobalHookFinished struct { - TestRunStartedId string `json:"testRunStartedId"` - HookId string `json:"hookId"` - Result *TestStepResult `json:"result"` - Timestamp *Timestamp `json:"timestamp"` + GlobalHookStartedId string `json:"globalHookStartedId"` + Result *TestStepResult `json:"result"` + Timestamp *Timestamp `json:"timestamp"` } type GlobalHookStarted struct { + Id string `json:"id"` TestRunStartedId string `json:"testRunStartedId"` HookId string `json:"hookId"` Timestamp *Timestamp `json:"timestamp"` diff --git a/java/src/generated/java/io/cucumber/messages/types/GlobalHookFinished.java b/java/src/generated/java/io/cucumber/messages/types/GlobalHookFinished.java index 145e0d3a..b38a549d 100644 --- a/java/src/generated/java/io/cucumber/messages/types/GlobalHookFinished.java +++ b/java/src/generated/java/io/cucumber/messages/types/GlobalHookFinished.java @@ -14,35 +14,25 @@ // Generated code @SuppressWarnings("unused") public final class GlobalHookFinished { - private final String testRunStartedId; - private final String hookId; + private final String globalHookStartedId; private final TestStepResult result; private final Timestamp timestamp; public GlobalHookFinished( - String testRunStartedId, - String hookId, + String globalHookStartedId, TestStepResult result, Timestamp timestamp ) { - this.testRunStartedId = requireNonNull(testRunStartedId, "GlobalHookFinished.testRunStartedId cannot be null"); - this.hookId = requireNonNull(hookId, "GlobalHookFinished.hookId cannot be null"); + this.globalHookStartedId = requireNonNull(globalHookStartedId, "GlobalHookFinished.globalHookStartedId cannot be null"); this.result = requireNonNull(result, "GlobalHookFinished.result cannot be null"); this.timestamp = requireNonNull(timestamp, "GlobalHookFinished.timestamp cannot be null"); } /** - * Identifier for the test run that this hook execution belongs to + * Identifier for the hook execution that has finished */ - public String getTestRunStartedId() { - return testRunStartedId; - } - - /** - * Identifier for the hook that was executed - */ - public String getHookId() { - return hookId; + public String getGlobalHookStartedId() { + return globalHookStartedId; } public TestStepResult getResult() { @@ -59,8 +49,7 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) return false; GlobalHookFinished that = (GlobalHookFinished) o; return - testRunStartedId.equals(that.testRunStartedId) && - hookId.equals(that.hookId) && + globalHookStartedId.equals(that.globalHookStartedId) && result.equals(that.result) && timestamp.equals(that.timestamp); } @@ -68,8 +57,7 @@ public boolean equals(Object o) { @Override public int hashCode() { return Objects.hash( - testRunStartedId, - hookId, + globalHookStartedId, result, timestamp ); @@ -78,8 +66,7 @@ public int hashCode() { @Override public String toString() { return "GlobalHookFinished{" + - "testRunStartedId=" + testRunStartedId + - ", hookId=" + hookId + + "globalHookStartedId=" + globalHookStartedId + ", result=" + result + ", timestamp=" + timestamp + '}'; diff --git a/java/src/generated/java/io/cucumber/messages/types/GlobalHookStarted.java b/java/src/generated/java/io/cucumber/messages/types/GlobalHookStarted.java index cbf73810..1ff87477 100644 --- a/java/src/generated/java/io/cucumber/messages/types/GlobalHookStarted.java +++ b/java/src/generated/java/io/cucumber/messages/types/GlobalHookStarted.java @@ -14,20 +14,30 @@ // Generated code @SuppressWarnings("unused") public final class GlobalHookStarted { + private final String id; private final String testRunStartedId; private final String hookId; private final Timestamp timestamp; public GlobalHookStarted( + String id, String testRunStartedId, String hookId, Timestamp timestamp ) { + this.id = requireNonNull(id, "GlobalHookStarted.id cannot be null"); this.testRunStartedId = requireNonNull(testRunStartedId, "GlobalHookStarted.testRunStartedId cannot be null"); this.hookId = requireNonNull(hookId, "GlobalHookStarted.hookId cannot be null"); this.timestamp = requireNonNull(timestamp, "GlobalHookStarted.timestamp cannot be null"); } + /** + * Unique identifier for this hook execution + */ + public String getId() { + return id; + } + /** * Identifier for the test run that this hook execution belongs to */ @@ -52,6 +62,7 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) return false; GlobalHookStarted that = (GlobalHookStarted) o; return + id.equals(that.id) && testRunStartedId.equals(that.testRunStartedId) && hookId.equals(that.hookId) && timestamp.equals(that.timestamp); @@ -60,6 +71,7 @@ public boolean equals(Object o) { @Override public int hashCode() { return Objects.hash( + id, testRunStartedId, hookId, timestamp @@ -69,7 +81,8 @@ public int hashCode() { @Override public String toString() { return "GlobalHookStarted{" + - "testRunStartedId=" + testRunStartedId + + "id=" + id + + ", testRunStartedId=" + testRunStartedId + ", hookId=" + hookId + ", timestamp=" + timestamp + '}'; diff --git a/javascript/src/messages.ts b/javascript/src/messages.ts index f61b5965..08e55678 100644 --- a/javascript/src/messages.ts +++ b/javascript/src/messages.ts @@ -314,9 +314,7 @@ export class Tag { export class GlobalHookFinished { - testRunStartedId: string = '' - - hookId: string = '' + globalHookStartedId: string = '' @Type(() => TestStepResult) result: TestStepResult = new TestStepResult() @@ -327,6 +325,8 @@ export class GlobalHookFinished { export class GlobalHookStarted { + id: string = '' + testRunStartedId: string = '' hookId: string = '' diff --git a/jsonschema/GlobalHookFinished.json b/jsonschema/GlobalHookFinished.json index 8f1c7245..e3b4a62a 100644 --- a/jsonschema/GlobalHookFinished.json +++ b/jsonschema/GlobalHookFinished.json @@ -3,18 +3,13 @@ "$id": "GlobalHookFinished.json", "additionalProperties": false, "required": [ - "testRunStartedId", - "hookId", + "globalHookStartedId", "result", "timestamp" ], "properties": { - "testRunStartedId": { - "description": "Identifier for the test run that this hook execution belongs to", - "type": "string" - }, - "hookId": { - "description": "Identifier for the hook that was executed", + "globalHookStartedId": { + "description": "Identifier for the hook execution that has finished", "type": "string" }, "result": { diff --git a/jsonschema/GlobalHookStarted.json b/jsonschema/GlobalHookStarted.json index 2ad48233..68b8561b 100644 --- a/jsonschema/GlobalHookStarted.json +++ b/jsonschema/GlobalHookStarted.json @@ -3,11 +3,16 @@ "$id": "GlobalHookStarted.json", "additionalProperties": false, "required": [ + "id", "testRunStartedId", "hookId", "timestamp" ], "properties": { + "id": { + "description": "Unique identifier for this hook execution", + "type": "string" + }, "testRunStartedId": { "description": "Identifier for the test run that this hook execution belongs to", "type": "string" diff --git a/messages.md b/messages.md index fad71a2e..e1c6112f 100644 --- a/messages.md +++ b/messages.md @@ -202,8 +202,7 @@ will only have one of its fields set, which indicates the payload of the message | Field | Type | Required | Description | | ----- | ---- | ----------- | ----------- | -| `testRunStartedId` | string | yes | | -| `hookId` | string | yes | | +| `globalHookStartedId` | string | yes | | | `result` | [TestStepResult](#teststepresult) | yes | | | `timestamp` | [Timestamp](#timestamp) | yes | | @@ -211,6 +210,7 @@ will only have one of its fields set, which indicates the payload of the message | Field | Type | Required | Description | | ----- | ---- | ----------- | ----------- | +| `id` | string | yes | | | `testRunStartedId` | string | yes | | | `hookId` | string | yes | | | `timestamp` | [Timestamp](#timestamp) | yes | | diff --git a/perl/lib/Cucumber/Messages.pm b/perl/lib/Cucumber/Messages.pm index f79dfd64..99822e76 100644 --- a/perl/lib/Cucumber/Messages.pm +++ b/perl/lib/Cucumber/Messages.pm @@ -2019,8 +2019,7 @@ extends 'Cucumber::Messages::Message'; use Scalar::Util qw( blessed ); my %types = ( - test_run_started_id => 'string', - hook_id => 'string', + global_hook_started_id => 'string', result => 'Cucumber::Messages::TestStepResult', timestamp => 'Cucumber::Messages::Timestamp', ); @@ -2033,24 +2032,12 @@ sub _types { -=head4 test_run_started_id - -Identifier for the test run that this hook execution belongs to -=cut - -has test_run_started_id => - (is => 'ro', - required => 1, - default => sub { '' }, - ); - - -=head4 hook_id +=head4 global_hook_started_id -Identifier for the hook that was executed +Identifier for the hook execution that has finished =cut -has hook_id => +has global_hook_started_id => (is => 'ro', required => 1, default => sub { '' }, @@ -2104,6 +2091,7 @@ extends 'Cucumber::Messages::Message'; use Scalar::Util qw( blessed ); my %types = ( + id => 'string', test_run_started_id => 'string', hook_id => 'string', timestamp => 'Cucumber::Messages::Timestamp', @@ -2117,6 +2105,18 @@ sub _types { +=head4 id + +Unique identifier for this hook execution +=cut + +has id => + (is => 'ro', + required => 1, + default => sub { '' }, + ); + + =head4 test_run_started_id Identifier for the test run that this hook execution belongs to diff --git a/php/src-generated/GlobalHookFinished.php b/php/src-generated/GlobalHookFinished.php index 00524200..65b73bab 100644 --- a/php/src-generated/GlobalHookFinished.php +++ b/php/src-generated/GlobalHookFinished.php @@ -27,14 +27,9 @@ final class GlobalHookFinished implements JsonSerializable public function __construct( /** - * Identifier for the test run that this hook execution belongs to + * Identifier for the hook execution that has finished */ - public readonly string $testRunStartedId = '', - - /** - * Identifier for the hook that was executed - */ - public readonly string $hookId = '', + public readonly string $globalHookStartedId = '', public readonly TestStepResult $result = new TestStepResult(), public readonly Timestamp $timestamp = new Timestamp(), ) { @@ -47,42 +42,27 @@ public function __construct( */ public static function fromArray(array $arr): self { - self::ensureTestRunStartedId($arr); - self::ensureHookId($arr); + self::ensureGlobalHookStartedId($arr); self::ensureResult($arr); self::ensureTimestamp($arr); return new self( - (string) $arr['testRunStartedId'], - (string) $arr['hookId'], + (string) $arr['globalHookStartedId'], TestStepResult::fromArray($arr['result']), Timestamp::fromArray($arr['timestamp']), ); } /** - * @psalm-assert array{testRunStartedId: string|int|bool} $arr - */ - private static function ensureTestRunStartedId(array $arr): void - { - if (!array_key_exists('testRunStartedId', $arr)) { - throw new SchemaViolationException('Property \'testRunStartedId\' is required but was not found'); - } - if (array_key_exists('testRunStartedId', $arr) && is_array($arr['testRunStartedId'])) { - throw new SchemaViolationException('Property \'testRunStartedId\' was array'); - } - } - - /** - * @psalm-assert array{hookId: string|int|bool} $arr + * @psalm-assert array{globalHookStartedId: string|int|bool} $arr */ - private static function ensureHookId(array $arr): void + private static function ensureGlobalHookStartedId(array $arr): void { - if (!array_key_exists('hookId', $arr)) { - throw new SchemaViolationException('Property \'hookId\' is required but was not found'); + if (!array_key_exists('globalHookStartedId', $arr)) { + throw new SchemaViolationException('Property \'globalHookStartedId\' is required but was not found'); } - if (array_key_exists('hookId', $arr) && is_array($arr['hookId'])) { - throw new SchemaViolationException('Property \'hookId\' was array'); + if (array_key_exists('globalHookStartedId', $arr) && is_array($arr['globalHookStartedId'])) { + throw new SchemaViolationException('Property \'globalHookStartedId\' was array'); } } diff --git a/php/src-generated/GlobalHookStarted.php b/php/src-generated/GlobalHookStarted.php index d13e112c..3179d654 100644 --- a/php/src-generated/GlobalHookStarted.php +++ b/php/src-generated/GlobalHookStarted.php @@ -26,6 +26,11 @@ final class GlobalHookStarted implements JsonSerializable */ public function __construct( + /** + * Unique identifier for this hook execution + */ + public readonly string $id = '', + /** * Identifier for the test run that this hook execution belongs to */ @@ -46,17 +51,32 @@ public function __construct( */ public static function fromArray(array $arr): self { + self::ensureId($arr); self::ensureTestRunStartedId($arr); self::ensureHookId($arr); self::ensureTimestamp($arr); return new self( + (string) $arr['id'], (string) $arr['testRunStartedId'], (string) $arr['hookId'], Timestamp::fromArray($arr['timestamp']), ); } + /** + * @psalm-assert array{id: string|int|bool} $arr + */ + private static function ensureId(array $arr): void + { + if (!array_key_exists('id', $arr)) { + throw new SchemaViolationException('Property \'id\' is required but was not found'); + } + if (array_key_exists('id', $arr) && is_array($arr['id'])) { + throw new SchemaViolationException('Property \'id\' was array'); + } + } + /** * @psalm-assert array{testRunStartedId: string|int|bool} $arr */ diff --git a/ruby/lib/cucumber/messages/global_hook_finished.rb b/ruby/lib/cucumber/messages/global_hook_finished.rb index 15e74fdc..18f835c9 100644 --- a/ruby/lib/cucumber/messages/global_hook_finished.rb +++ b/ruby/lib/cucumber/messages/global_hook_finished.rb @@ -9,27 +9,20 @@ module Messages ## class GlobalHookFinished < Message ## - # Identifier for the test run that this hook execution belongs to + # Identifier for the hook execution that has finished ## - attr_reader :test_run_started_id - - ## - # Identifier for the hook that was executed - ## - attr_reader :hook_id + attr_reader :global_hook_started_id attr_reader :result attr_reader :timestamp def initialize( - test_run_started_id: '', - hook_id: '', + global_hook_started_id: '', result: TestStepResult.new, timestamp: Timestamp.new ) - @test_run_started_id = test_run_started_id - @hook_id = hook_id + @global_hook_started_id = global_hook_started_id @result = result @timestamp = timestamp super() @@ -46,8 +39,7 @@ def self.from_h(hash) return nil if hash.nil? new( - test_run_started_id: hash[:testRunStartedId], - hook_id: hash[:hookId], + global_hook_started_id: hash[:globalHookStartedId], result: TestStepResult.from_h(hash[:result]), timestamp: Timestamp.from_h(hash[:timestamp]) ) diff --git a/ruby/lib/cucumber/messages/global_hook_started.rb b/ruby/lib/cucumber/messages/global_hook_started.rb index 62577ff4..0ef82d03 100644 --- a/ruby/lib/cucumber/messages/global_hook_started.rb +++ b/ruby/lib/cucumber/messages/global_hook_started.rb @@ -8,6 +8,11 @@ module Messages ## ## class GlobalHookStarted < Message + ## + # Unique identifier for this hook execution + ## + attr_reader :id + ## # Identifier for the test run that this hook execution belongs to ## @@ -21,10 +26,12 @@ class GlobalHookStarted < Message attr_reader :timestamp def initialize( + id: '', test_run_started_id: '', hook_id: '', timestamp: Timestamp.new ) + @id = id @test_run_started_id = test_run_started_id @hook_id = hook_id @timestamp = timestamp @@ -42,6 +49,7 @@ def self.from_h(hash) return nil if hash.nil? new( + id: hash[:id], test_run_started_id: hash[:testRunStartedId], hook_id: hash[:hookId], timestamp: Timestamp.from_h(hash[:timestamp]) From 521bb633d2ad05d25d5f809bcb77c6dfd509dabc Mon Sep 17 00:00:00 2001 From: David Goss Date: Fri, 20 Sep 2024 20:13:53 +0100 Subject: [PATCH 10/18] recast as TestRunHook(Started|Finished) --- CHANGELOG.md | 2 +- Makefile | 4 +- .../messages/cucumber/messages/all.hpp | 4 +- .../messages/cucumber/messages/envelope.hpp | 8 +- ...inished.hpp => test_run_hook_finished.hpp} | 10 +- ..._started.hpp => test_run_hook_started.hpp} | 8 +- .../messages/cucumber/messages/envelope.cpp | 8 +- .../messages/test_run_hook_finished.cpp | 52 +++ .../messages/test_run_hook_started.cpp | 54 +++ .../Cucumber.Messages/generated/Envelope.cs | 36 +- ...HookFinished.cs => TestRunHookFinished.cs} | 30 +- ...alHookStarted.cs => TestRunHookStarted.cs} | 18 +- go/messages.go | 30 +- .../io/cucumber/messages/types/Envelope.java | 40 +-- ...Finished.java => TestRunHookFinished.java} | 30 +- ...okStarted.java => TestRunHookStarted.java} | 18 +- javascript/src/messages.ts | 54 +-- jsonschema/Envelope.json | 8 +- ...Finished.json => TestRunHookFinished.json} | 6 +- ...okStarted.json => TestRunHookStarted.json} | 2 +- messages.md | 38 +- perl/lib/Cucumber/Messages.pm | 326 +++++++++--------- php/src-generated/Envelope.php | 28 +- ...okFinished.php => TestRunHookFinished.php} | 24 +- ...HookStarted.php => TestRunHookStarted.php} | 6 +- ruby/lib/cucumber/messages/envelope.rb | 16 +- ..._finished.rb => test_run_hook_finished.rb} | 16 +- ...ok_started.rb => test_run_hook_started.rb} | 8 +- 28 files changed, 495 insertions(+), 389 deletions(-) rename cpp/include/messages/cucumber/messages/{global_hook_finished.hpp => test_run_hook_finished.hpp} (68%) rename cpp/include/messages/cucumber/messages/{global_hook_started.hpp => test_run_hook_started.hpp} (71%) create mode 100644 cpp/src/lib/messages/cucumber/messages/test_run_hook_finished.cpp create mode 100644 cpp/src/lib/messages/cucumber/messages/test_run_hook_started.cpp rename dotnet/Cucumber.Messages/generated/{GlobalHookFinished.cs => TestRunHookFinished.cs} (69%) rename dotnet/Cucumber.Messages/generated/{GlobalHookStarted.cs => TestRunHookStarted.cs} (83%) rename java/src/generated/java/io/cucumber/messages/types/{GlobalHookFinished.java => TestRunHookFinished.java} (58%) rename java/src/generated/java/io/cucumber/messages/types/{GlobalHookStarted.java => TestRunHookStarted.java} (77%) rename jsonschema/{GlobalHookFinished.json => TestRunHookFinished.json} (81%) rename jsonschema/{GlobalHookStarted.json => TestRunHookStarted.json} (94%) rename php/src-generated/{GlobalHookFinished.php => TestRunHookFinished.php} (69%) rename php/src-generated/{GlobalHookStarted.php => TestRunHookStarted.php} (94%) rename ruby/lib/cucumber/messages/{global_hook_finished.rb => test_run_hook_finished.rb} (61%) rename ruby/lib/cucumber/messages/{global_hook_started.rb => test_run_hook_started.rb} (78%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d06b8c9..48f831aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [26.0.0] - 2024-08-15 ### Added - BREAKING CHANGE: Add `id` property to `TestRunStarted`, optionally reference in `Attachment`, TestCase` and `TestRunFinished` ([#102](https://github.com/cucumber/messages/pull/102)) -- Add new `GlobalHookStarted` and `GlobalHookFinished` messages ([#102](https://github.com/cucumber/messages/pull/102)) +- Add new `TestRunHookStarted` and `TestRunHookFinished` messages ([#102](https://github.com/cucumber/messages/pull/102)) - [Dotnet] Added support classes aligned with what is provided for the Java implementation (https://github.com/cucumber/messages/pull/233 [clrudolphi](https://github.com/clrudolphi)) ### Changed diff --git a/Makefile b/Makefile index cb89b0a1..297f25ec 100644 --- a/Makefile +++ b/Makefile @@ -22,8 +22,8 @@ schemas = \ ./jsonschema/TestStepResult.json \ ./jsonschema/TestStepFinished.json \ ./jsonschema/TestStepStarted.json \ - ./jsonschema/GlobalHookFinished.json \ - ./jsonschema/GlobalHookStarted.json \ + ./jsonschema/TestRunHookFinished.json \ + ./jsonschema/TestRunHookStarted.json \ ./jsonschema/UndefinedParameterType.json \ ./jsonschema/Envelope.json diff --git a/cpp/include/messages/cucumber/messages/all.hpp b/cpp/include/messages/cucumber/messages/all.hpp index a90d728e..18507d0a 100644 --- a/cpp/include/messages/cucumber/messages/all.hpp +++ b/cpp/include/messages/cucumber/messages/all.hpp @@ -17,8 +17,6 @@ #include #include #include -#include -#include #include #include #include @@ -49,6 +47,8 @@ #include #include #include +#include +#include #include #include #include diff --git a/cpp/include/messages/cucumber/messages/envelope.hpp b/cpp/include/messages/cucumber/messages/envelope.hpp index a6c3a236..52fa6cdc 100644 --- a/cpp/include/messages/cucumber/messages/envelope.hpp +++ b/cpp/include/messages/cucumber/messages/envelope.hpp @@ -22,8 +22,8 @@ #include #include #include -#include -#include +#include +#include #include namespace cucumber::messages { @@ -61,8 +61,8 @@ struct envelope std::optional test_run_started; std::optional test_step_finished; std::optional test_step_started; - std::optional global_hook_started; - std::optional global_hook_finished; + std::optional test_run_hook_started; + std::optional test_run_hook_finished; std::optional undefined_parameter_type; std::string to_string() const; diff --git a/cpp/include/messages/cucumber/messages/global_hook_finished.hpp b/cpp/include/messages/cucumber/messages/test_run_hook_finished.hpp similarity index 68% rename from cpp/include/messages/cucumber/messages/global_hook_finished.hpp rename to cpp/include/messages/cucumber/messages/test_run_hook_finished.hpp index d87d952c..6fb4de76 100644 --- a/cpp/include/messages/cucumber/messages/global_hook_finished.hpp +++ b/cpp/include/messages/cucumber/messages/test_run_hook_finished.hpp @@ -14,14 +14,14 @@ namespace cucumber::messages { using json = nlohmann::json; // -// Represents the GlobalHookFinished message in Cucumber's message protocol +// Represents the TestRunHookFinished message in Cucumber's message protocol // @see Github - Cucumber - Messages // // Generated code -struct global_hook_finished +struct test_run_hook_finished { - std::string global_hook_started_id; + std::string test_run_hook_started_id; cucumber::messages::test_step_result result; cucumber::messages::timestamp timestamp; @@ -32,8 +32,8 @@ struct global_hook_finished }; std::ostream& -operator<<(std::ostream& os, const global_hook_finished& msg); +operator<<(std::ostream& os, const test_run_hook_finished& msg); -void to_json(json& j, const global_hook_finished& m); +void to_json(json& j, const test_run_hook_finished& m); } diff --git a/cpp/include/messages/cucumber/messages/global_hook_started.hpp b/cpp/include/messages/cucumber/messages/test_run_hook_started.hpp similarity index 71% rename from cpp/include/messages/cucumber/messages/global_hook_started.hpp rename to cpp/include/messages/cucumber/messages/test_run_hook_started.hpp index bea25c77..5293b467 100644 --- a/cpp/include/messages/cucumber/messages/global_hook_started.hpp +++ b/cpp/include/messages/cucumber/messages/test_run_hook_started.hpp @@ -13,12 +13,12 @@ namespace cucumber::messages { using json = nlohmann::json; // -// Represents the GlobalHookStarted message in Cucumber's message protocol +// Represents the TestRunHookStarted message in Cucumber's message protocol // @see Github - Cucumber - Messages // // Generated code -struct global_hook_started +struct test_run_hook_started { std::string id; std::string test_run_started_id; @@ -32,8 +32,8 @@ struct global_hook_started }; std::ostream& -operator<<(std::ostream& os, const global_hook_started& msg); +operator<<(std::ostream& os, const test_run_hook_started& msg); -void to_json(json& j, const global_hook_started& m); +void to_json(json& j, const test_run_hook_started& m); } diff --git a/cpp/src/lib/messages/cucumber/messages/envelope.cpp b/cpp/src/lib/messages/cucumber/messages/envelope.cpp index 6884c8a5..e780f0c7 100644 --- a/cpp/src/lib/messages/cucumber/messages/envelope.cpp +++ b/cpp/src/lib/messages/cucumber/messages/envelope.cpp @@ -26,8 +26,8 @@ envelope::to_string() const cucumber::messages::to_string(oss, ", test_run_started=", test_run_started); cucumber::messages::to_string(oss, ", test_step_finished=", test_step_finished); cucumber::messages::to_string(oss, ", test_step_started=", test_step_started); - cucumber::messages::to_string(oss, ", global_hook_started=", global_hook_started); - cucumber::messages::to_string(oss, ", global_hook_finished=", global_hook_finished); + cucumber::messages::to_string(oss, ", test_run_hook_started=", test_run_hook_started); + cucumber::messages::to_string(oss, ", test_run_hook_finished=", test_run_hook_finished); cucumber::messages::to_string(oss, ", undefined_parameter_type=", undefined_parameter_type); return oss.str(); @@ -52,8 +52,8 @@ envelope::to_json(json& j) const cucumber::messages::to_json(j, camelize("test_run_started"), test_run_started); cucumber::messages::to_json(j, camelize("test_step_finished"), test_step_finished); cucumber::messages::to_json(j, camelize("test_step_started"), test_step_started); - cucumber::messages::to_json(j, camelize("global_hook_started"), global_hook_started); - cucumber::messages::to_json(j, camelize("global_hook_finished"), global_hook_finished); + cucumber::messages::to_json(j, camelize("test_run_hook_started"), test_run_hook_started); + cucumber::messages::to_json(j, camelize("test_run_hook_finished"), test_run_hook_finished); cucumber::messages::to_json(j, camelize("undefined_parameter_type"), undefined_parameter_type); } diff --git a/cpp/src/lib/messages/cucumber/messages/test_run_hook_finished.cpp b/cpp/src/lib/messages/cucumber/messages/test_run_hook_finished.cpp new file mode 100644 index 00000000..a850dcd6 --- /dev/null +++ b/cpp/src/lib/messages/cucumber/messages/test_run_hook_finished.cpp @@ -0,0 +1,52 @@ +#include + +#include +#include + +namespace cucumber::messages { + +std::string +test_run_hook_finished::to_string() const +{ + std::ostringstream oss; + + cucumber::messages::to_string(oss, "test_run_hook_started_id=", test_run_hook_started_id); + cucumber::messages::to_string(oss, ", result=", result); + cucumber::messages::to_string(oss, ", timestamp=", timestamp); + + return oss.str(); +} + +void +test_run_hook_finished::to_json(json& j) const +{ + cucumber::messages::to_json(j, camelize("test_run_hook_started_id"), test_run_hook_started_id); + cucumber::messages::to_json(j, camelize("result"), result); + cucumber::messages::to_json(j, camelize("timestamp"), timestamp); +} + +std::string +test_run_hook_finished::to_json() const +{ + std::ostringstream oss; + json j; + + to_json(j); + + oss << j; + + return oss.str(); +} + +std::ostream& +operator<<(std::ostream& os, const test_run_hook_finished& msg) +{ + os << msg.to_string(); + + return os; +} + +void to_json(json& j, const test_run_hook_finished& m) +{ m.to_json(j); } + +} diff --git a/cpp/src/lib/messages/cucumber/messages/test_run_hook_started.cpp b/cpp/src/lib/messages/cucumber/messages/test_run_hook_started.cpp new file mode 100644 index 00000000..6cfda313 --- /dev/null +++ b/cpp/src/lib/messages/cucumber/messages/test_run_hook_started.cpp @@ -0,0 +1,54 @@ +#include + +#include +#include + +namespace cucumber::messages { + +std::string +test_run_hook_started::to_string() const +{ + std::ostringstream oss; + + cucumber::messages::to_string(oss, "id=", id); + cucumber::messages::to_string(oss, ", test_run_started_id=", test_run_started_id); + cucumber::messages::to_string(oss, ", hook_id=", hook_id); + cucumber::messages::to_string(oss, ", timestamp=", timestamp); + + return oss.str(); +} + +void +test_run_hook_started::to_json(json& j) const +{ + cucumber::messages::to_json(j, camelize("id"), id); + cucumber::messages::to_json(j, camelize("test_run_started_id"), test_run_started_id); + cucumber::messages::to_json(j, camelize("hook_id"), hook_id); + cucumber::messages::to_json(j, camelize("timestamp"), timestamp); +} + +std::string +test_run_hook_started::to_json() const +{ + std::ostringstream oss; + json j; + + to_json(j); + + oss << j; + + return oss.str(); +} + +std::ostream& +operator<<(std::ostream& os, const test_run_hook_started& msg) +{ + os << msg.to_string(); + + return os; +} + +void to_json(json& j, const test_run_hook_started& m) +{ m.to_json(j); } + +} diff --git a/dotnet/Cucumber.Messages/generated/Envelope.cs b/dotnet/Cucumber.Messages/generated/Envelope.cs index aabdcab4..dadd1558 100644 --- a/dotnet/Cucumber.Messages/generated/Envelope.cs +++ b/dotnet/Cucumber.Messages/generated/Envelope.cs @@ -39,8 +39,8 @@ public sealed class Envelope public TestRunStarted TestRunStarted { get; private set; } public TestStepFinished TestStepFinished { get; private set; } public TestStepStarted TestStepStarted { get; private set; } - public GlobalHookStarted GlobalHookStarted { get; private set; } - public GlobalHookFinished GlobalHookFinished { get; private set; } + public TestRunHookStarted TestRunHookStarted { get; private set; } + public TestRunHookFinished TestRunHookFinished { get; private set; } public UndefinedParameterType UndefinedParameterType { get; private set; } @@ -444,7 +444,7 @@ public static Envelope Create(TestStepStarted testStepStarted) ); } - public static Envelope Create(GlobalHookStarted globalHookStarted) + public static Envelope Create(TestRunHookStarted testRunHookStarted) { return new Envelope( null, @@ -463,13 +463,13 @@ public static Envelope Create(GlobalHookStarted globalHookStarted) null, null, null, - Require(globalHookStarted, "GlobalHookStarted", "Envelope.GlobalHookStarted cannot be null"), + Require(testRunHookStarted, "TestRunHookStarted", "Envelope.TestRunHookStarted cannot be null"), null, null ); } - public static Envelope Create(GlobalHookFinished globalHookFinished) + public static Envelope Create(TestRunHookFinished testRunHookFinished) { return new Envelope( null, @@ -489,7 +489,7 @@ public static Envelope Create(GlobalHookFinished globalHookFinished) null, null, null, - Require(globalHookFinished, "GlobalHookFinished", "Envelope.GlobalHookFinished cannot be null"), + Require(testRunHookFinished, "TestRunHookFinished", "Envelope.TestRunHookFinished cannot be null"), null ); } @@ -536,8 +536,8 @@ public Envelope( TestRunStarted testRunStarted, TestStepFinished testStepFinished, TestStepStarted testStepStarted, - GlobalHookStarted globalHookStarted, - GlobalHookFinished globalHookFinished, + TestRunHookStarted testRunHookStarted, + TestRunHookFinished testRunHookFinished, UndefinedParameterType undefinedParameterType ) { @@ -557,8 +557,8 @@ UndefinedParameterType undefinedParameterType this.TestRunStarted = testRunStarted; this.TestStepFinished = testStepFinished; this.TestStepStarted = testStepStarted; - this.GlobalHookStarted = globalHookStarted; - this.GlobalHookFinished = globalHookFinished; + this.TestRunHookStarted = testRunHookStarted; + this.TestRunHookFinished = testRunHookFinished; this.UndefinedParameterType = undefinedParameterType; } @@ -584,8 +584,8 @@ public override bool Equals(Object o) Object.Equals(TestRunStarted, that.TestRunStarted) && Object.Equals(TestStepFinished, that.TestStepFinished) && Object.Equals(TestStepStarted, that.TestStepStarted) && - Object.Equals(GlobalHookStarted, that.GlobalHookStarted) && - Object.Equals(GlobalHookFinished, that.GlobalHookFinished) && + Object.Equals(TestRunHookStarted, that.TestRunHookStarted) && + Object.Equals(TestRunHookFinished, that.TestRunHookFinished) && Object.Equals(UndefinedParameterType, that.UndefinedParameterType); } @@ -624,10 +624,10 @@ public override int GetHashCode() hash = hash * 31 + TestStepFinished.GetHashCode(); if (TestStepStarted != null) hash = hash * 31 + TestStepStarted.GetHashCode(); - if (GlobalHookStarted != null) - hash = hash * 31 + GlobalHookStarted.GetHashCode(); - if (GlobalHookFinished != null) - hash = hash * 31 + GlobalHookFinished.GetHashCode(); + if (TestRunHookStarted != null) + hash = hash * 31 + TestRunHookStarted.GetHashCode(); + if (TestRunHookFinished != null) + hash = hash * 31 + TestRunHookFinished.GetHashCode(); if (UndefinedParameterType != null) hash = hash * 31 + UndefinedParameterType.GetHashCode(); return hash; @@ -652,8 +652,8 @@ public override string ToString() ", testRunStarted=" + TestRunStarted + ", testStepFinished=" + TestStepFinished + ", testStepStarted=" + TestStepStarted + - ", globalHookStarted=" + GlobalHookStarted + - ", globalHookFinished=" + GlobalHookFinished + + ", testRunHookStarted=" + TestRunHookStarted + + ", testRunHookFinished=" + TestRunHookFinished + ", undefinedParameterType=" + UndefinedParameterType + '}'; } diff --git a/dotnet/Cucumber.Messages/generated/GlobalHookFinished.cs b/dotnet/Cucumber.Messages/generated/TestRunHookFinished.cs similarity index 69% rename from dotnet/Cucumber.Messages/generated/GlobalHookFinished.cs rename to dotnet/Cucumber.Messages/generated/TestRunHookFinished.cs index d850eb20..74150dc4 100644 --- a/dotnet/Cucumber.Messages/generated/GlobalHookFinished.cs +++ b/dotnet/Cucumber.Messages/generated/TestRunHookFinished.cs @@ -10,31 +10,31 @@ namespace Io.Cucumber.Messages.Types; /** - * Represents the GlobalHookFinished message in Cucumber's message protocol + * Represents the TestRunHookFinished message in Cucumber's message protocol * @see Github - Cucumber - Messages */ -public sealed class GlobalHookFinished +public sealed class TestRunHookFinished { /** * Identifier for the hook execution that has finished */ - public string GlobalHookStartedId { get; private set; } + public string TestRunHookStartedId { get; private set; } public TestStepResult Result { get; private set; } public Timestamp Timestamp { get; private set; } - public GlobalHookFinished( - string globalHookStartedId, + public TestRunHookFinished( + string testRunHookStartedId, TestStepResult result, Timestamp timestamp ) { - RequireNonNull(globalHookStartedId, "GlobalHookStartedId", "GlobalHookFinished.GlobalHookStartedId cannot be null"); - this.GlobalHookStartedId = globalHookStartedId; - RequireNonNull(result, "Result", "GlobalHookFinished.Result cannot be null"); + RequireNonNull(testRunHookStartedId, "TestRunHookStartedId", "TestRunHookFinished.TestRunHookStartedId cannot be null"); + this.TestRunHookStartedId = testRunHookStartedId; + RequireNonNull(result, "Result", "TestRunHookFinished.Result cannot be null"); this.Result = result; - RequireNonNull(timestamp, "Timestamp", "GlobalHookFinished.Timestamp cannot be null"); + RequireNonNull(timestamp, "Timestamp", "TestRunHookFinished.Timestamp cannot be null"); this.Timestamp = timestamp; } @@ -42,9 +42,9 @@ public override bool Equals(Object o) { if (this == o) return true; if (o == null || this.GetType() != o.GetType()) return false; - GlobalHookFinished that = (GlobalHookFinished) o; + TestRunHookFinished that = (TestRunHookFinished) o; return - GlobalHookStartedId.Equals(that.GlobalHookStartedId) && + TestRunHookStartedId.Equals(that.TestRunHookStartedId) && Result.Equals(that.Result) && Timestamp.Equals(that.Timestamp); } @@ -52,8 +52,8 @@ public override bool Equals(Object o) public override int GetHashCode() { int hash = 17; - if (GlobalHookStartedId != null) - hash = hash * 31 + GlobalHookStartedId.GetHashCode(); + if (TestRunHookStartedId != null) + hash = hash * 31 + TestRunHookStartedId.GetHashCode(); if (Result != null) hash = hash * 31 + Result.GetHashCode(); if (Timestamp != null) @@ -63,8 +63,8 @@ public override int GetHashCode() public override string ToString() { - return "GlobalHookFinished{" + - "globalHookStartedId=" + GlobalHookStartedId + + return "TestRunHookFinished{" + + "testRunHookStartedId=" + TestRunHookStartedId + ", result=" + Result + ", timestamp=" + Timestamp + '}'; diff --git a/dotnet/Cucumber.Messages/generated/GlobalHookStarted.cs b/dotnet/Cucumber.Messages/generated/TestRunHookStarted.cs similarity index 83% rename from dotnet/Cucumber.Messages/generated/GlobalHookStarted.cs rename to dotnet/Cucumber.Messages/generated/TestRunHookStarted.cs index ce7a33a6..67e284bc 100644 --- a/dotnet/Cucumber.Messages/generated/GlobalHookStarted.cs +++ b/dotnet/Cucumber.Messages/generated/TestRunHookStarted.cs @@ -10,11 +10,11 @@ namespace Io.Cucumber.Messages.Types; /** - * Represents the GlobalHookStarted message in Cucumber's message protocol + * Represents the TestRunHookStarted message in Cucumber's message protocol * @see Github - Cucumber - Messages */ -public sealed class GlobalHookStarted +public sealed class TestRunHookStarted { /** * Unique identifier for this hook execution @@ -31,20 +31,20 @@ public sealed class GlobalHookStarted public Timestamp Timestamp { get; private set; } - public GlobalHookStarted( + public TestRunHookStarted( string id, string testRunStartedId, string hookId, Timestamp timestamp ) { - RequireNonNull(id, "Id", "GlobalHookStarted.Id cannot be null"); + RequireNonNull(id, "Id", "TestRunHookStarted.Id cannot be null"); this.Id = id; - RequireNonNull(testRunStartedId, "TestRunStartedId", "GlobalHookStarted.TestRunStartedId cannot be null"); + RequireNonNull(testRunStartedId, "TestRunStartedId", "TestRunHookStarted.TestRunStartedId cannot be null"); this.TestRunStartedId = testRunStartedId; - RequireNonNull(hookId, "HookId", "GlobalHookStarted.HookId cannot be null"); + RequireNonNull(hookId, "HookId", "TestRunHookStarted.HookId cannot be null"); this.HookId = hookId; - RequireNonNull(timestamp, "Timestamp", "GlobalHookStarted.Timestamp cannot be null"); + RequireNonNull(timestamp, "Timestamp", "TestRunHookStarted.Timestamp cannot be null"); this.Timestamp = timestamp; } @@ -52,7 +52,7 @@ public override bool Equals(Object o) { if (this == o) return true; if (o == null || this.GetType() != o.GetType()) return false; - GlobalHookStarted that = (GlobalHookStarted) o; + TestRunHookStarted that = (TestRunHookStarted) o; return Id.Equals(that.Id) && TestRunStartedId.Equals(that.TestRunStartedId) && @@ -76,7 +76,7 @@ public override int GetHashCode() public override string ToString() { - return "GlobalHookStarted{" + + return "TestRunHookStarted{" + "id=" + Id + ", testRunStartedId=" + TestRunStartedId + ", hookId=" + HookId + diff --git a/go/messages.go b/go/messages.go index 0322c670..4bf3d7a1 100644 --- a/go/messages.go +++ b/go/messages.go @@ -34,8 +34,8 @@ type Envelope struct { TestRunStarted *TestRunStarted `json:"testRunStarted,omitempty"` TestStepFinished *TestStepFinished `json:"testStepFinished,omitempty"` TestStepStarted *TestStepStarted `json:"testStepStarted,omitempty"` - GlobalHookStarted *GlobalHookStarted `json:"globalHookStarted,omitempty"` - GlobalHookFinished *GlobalHookFinished `json:"globalHookFinished,omitempty"` + TestRunHookStarted *TestRunHookStarted `json:"testRunHookStarted,omitempty"` + TestRunHookFinished *TestRunHookFinished `json:"testRunHookFinished,omitempty"` UndefinedParameterType *UndefinedParameterType `json:"undefinedParameterType,omitempty"` } @@ -157,19 +157,6 @@ type Tag struct { Id string `json:"id"` } -type GlobalHookFinished struct { - GlobalHookStartedId string `json:"globalHookStartedId"` - Result *TestStepResult `json:"result"` - Timestamp *Timestamp `json:"timestamp"` -} - -type GlobalHookStarted struct { - Id string `json:"id"` - TestRunStartedId string `json:"testRunStartedId"` - HookId string `json:"hookId"` - Timestamp *Timestamp `json:"timestamp"` -} - type Hook struct { Id string `json:"id"` Name string `json:"name,omitempty"` @@ -357,6 +344,19 @@ type TestRunFinished struct { TestRunStartedId string `json:"testRunStartedId,omitempty"` } +type TestRunHookFinished struct { + TestRunHookStartedId string `json:"testRunHookStartedId"` + Result *TestStepResult `json:"result"` + Timestamp *Timestamp `json:"timestamp"` +} + +type TestRunHookStarted struct { + Id string `json:"id"` + TestRunStartedId string `json:"testRunStartedId"` + HookId string `json:"hookId"` + Timestamp *Timestamp `json:"timestamp"` +} + type TestRunStarted struct { Timestamp *Timestamp `json:"timestamp"` Id string `json:"id,omitempty"` diff --git a/java/src/generated/java/io/cucumber/messages/types/Envelope.java b/java/src/generated/java/io/cucumber/messages/types/Envelope.java index c2079898..2aaf01af 100644 --- a/java/src/generated/java/io/cucumber/messages/types/Envelope.java +++ b/java/src/generated/java/io/cucumber/messages/types/Envelope.java @@ -37,8 +37,8 @@ public final class Envelope { private final TestRunStarted testRunStarted; private final TestStepFinished testStepFinished; private final TestStepStarted testStepStarted; - private final GlobalHookStarted globalHookStarted; - private final GlobalHookFinished globalHookFinished; + private final TestRunHookStarted testRunHookStarted; + private final TestRunHookFinished testRunHookFinished; private final UndefinedParameterType undefinedParameterType; public static Envelope of(Attachment attachment) { @@ -425,7 +425,7 @@ public static Envelope of(TestStepStarted testStepStarted) { ); } - public static Envelope of(GlobalHookStarted globalHookStarted) { + public static Envelope of(TestRunHookStarted testRunHookStarted) { return new Envelope( null, null, @@ -443,13 +443,13 @@ public static Envelope of(GlobalHookStarted globalHookStarted) { null, null, null, - requireNonNull(globalHookStarted, "Envelope.globalHookStarted cannot be null"), + requireNonNull(testRunHookStarted, "Envelope.testRunHookStarted cannot be null"), null, null ); } - public static Envelope of(GlobalHookFinished globalHookFinished) { + public static Envelope of(TestRunHookFinished testRunHookFinished) { return new Envelope( null, null, @@ -468,7 +468,7 @@ public static Envelope of(GlobalHookFinished globalHookFinished) { null, null, null, - requireNonNull(globalHookFinished, "Envelope.globalHookFinished cannot be null"), + requireNonNull(testRunHookFinished, "Envelope.testRunHookFinished cannot be null"), null ); } @@ -514,8 +514,8 @@ public Envelope( TestRunStarted testRunStarted, TestStepFinished testStepFinished, TestStepStarted testStepStarted, - GlobalHookStarted globalHookStarted, - GlobalHookFinished globalHookFinished, + TestRunHookStarted testRunHookStarted, + TestRunHookFinished testRunHookFinished, UndefinedParameterType undefinedParameterType ) { this.attachment = attachment; @@ -534,8 +534,8 @@ public Envelope( this.testRunStarted = testRunStarted; this.testStepFinished = testStepFinished; this.testStepStarted = testStepStarted; - this.globalHookStarted = globalHookStarted; - this.globalHookFinished = globalHookFinished; + this.testRunHookStarted = testRunHookStarted; + this.testRunHookFinished = testRunHookFinished; this.undefinedParameterType = undefinedParameterType; } @@ -603,12 +603,12 @@ public Optional getTestStepStarted() { return Optional.ofNullable(testStepStarted); } - public Optional getGlobalHookStarted() { - return Optional.ofNullable(globalHookStarted); + public Optional getTestRunHookStarted() { + return Optional.ofNullable(testRunHookStarted); } - public Optional getGlobalHookFinished() { - return Optional.ofNullable(globalHookFinished); + public Optional getTestRunHookFinished() { + return Optional.ofNullable(testRunHookFinished); } public Optional getUndefinedParameterType() { @@ -637,8 +637,8 @@ public boolean equals(Object o) { Objects.equals(testRunStarted, that.testRunStarted) && Objects.equals(testStepFinished, that.testStepFinished) && Objects.equals(testStepStarted, that.testStepStarted) && - Objects.equals(globalHookStarted, that.globalHookStarted) && - Objects.equals(globalHookFinished, that.globalHookFinished) && + Objects.equals(testRunHookStarted, that.testRunHookStarted) && + Objects.equals(testRunHookFinished, that.testRunHookFinished) && Objects.equals(undefinedParameterType, that.undefinedParameterType); } @@ -661,8 +661,8 @@ public int hashCode() { testRunStarted, testStepFinished, testStepStarted, - globalHookStarted, - globalHookFinished, + testRunHookStarted, + testRunHookFinished, undefinedParameterType ); } @@ -686,8 +686,8 @@ public String toString() { ", testRunStarted=" + testRunStarted + ", testStepFinished=" + testStepFinished + ", testStepStarted=" + testStepStarted + - ", globalHookStarted=" + globalHookStarted + - ", globalHookFinished=" + globalHookFinished + + ", testRunHookStarted=" + testRunHookStarted + + ", testRunHookFinished=" + testRunHookFinished + ", undefinedParameterType=" + undefinedParameterType + '}'; } diff --git a/java/src/generated/java/io/cucumber/messages/types/GlobalHookFinished.java b/java/src/generated/java/io/cucumber/messages/types/TestRunHookFinished.java similarity index 58% rename from java/src/generated/java/io/cucumber/messages/types/GlobalHookFinished.java rename to java/src/generated/java/io/cucumber/messages/types/TestRunHookFinished.java index b38a549d..3e519319 100644 --- a/java/src/generated/java/io/cucumber/messages/types/GlobalHookFinished.java +++ b/java/src/generated/java/io/cucumber/messages/types/TestRunHookFinished.java @@ -8,31 +8,31 @@ import static java.util.Objects.requireNonNull; /** - * Represents the GlobalHookFinished message in Cucumber's message protocol + * Represents the TestRunHookFinished message in Cucumber's message protocol * @see Github - Cucumber - Messages */ // Generated code @SuppressWarnings("unused") -public final class GlobalHookFinished { - private final String globalHookStartedId; +public final class TestRunHookFinished { + private final String testRunHookStartedId; private final TestStepResult result; private final Timestamp timestamp; - public GlobalHookFinished( - String globalHookStartedId, + public TestRunHookFinished( + String testRunHookStartedId, TestStepResult result, Timestamp timestamp ) { - this.globalHookStartedId = requireNonNull(globalHookStartedId, "GlobalHookFinished.globalHookStartedId cannot be null"); - this.result = requireNonNull(result, "GlobalHookFinished.result cannot be null"); - this.timestamp = requireNonNull(timestamp, "GlobalHookFinished.timestamp cannot be null"); + this.testRunHookStartedId = requireNonNull(testRunHookStartedId, "TestRunHookFinished.testRunHookStartedId cannot be null"); + this.result = requireNonNull(result, "TestRunHookFinished.result cannot be null"); + this.timestamp = requireNonNull(timestamp, "TestRunHookFinished.timestamp cannot be null"); } /** * Identifier for the hook execution that has finished */ - public String getGlobalHookStartedId() { - return globalHookStartedId; + public String getTestRunHookStartedId() { + return testRunHookStartedId; } public TestStepResult getResult() { @@ -47,9 +47,9 @@ public Timestamp getTimestamp() { public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - GlobalHookFinished that = (GlobalHookFinished) o; + TestRunHookFinished that = (TestRunHookFinished) o; return - globalHookStartedId.equals(that.globalHookStartedId) && + testRunHookStartedId.equals(that.testRunHookStartedId) && result.equals(that.result) && timestamp.equals(that.timestamp); } @@ -57,7 +57,7 @@ public boolean equals(Object o) { @Override public int hashCode() { return Objects.hash( - globalHookStartedId, + testRunHookStartedId, result, timestamp ); @@ -65,8 +65,8 @@ public int hashCode() { @Override public String toString() { - return "GlobalHookFinished{" + - "globalHookStartedId=" + globalHookStartedId + + return "TestRunHookFinished{" + + "testRunHookStartedId=" + testRunHookStartedId + ", result=" + result + ", timestamp=" + timestamp + '}'; diff --git a/java/src/generated/java/io/cucumber/messages/types/GlobalHookStarted.java b/java/src/generated/java/io/cucumber/messages/types/TestRunHookStarted.java similarity index 77% rename from java/src/generated/java/io/cucumber/messages/types/GlobalHookStarted.java rename to java/src/generated/java/io/cucumber/messages/types/TestRunHookStarted.java index 1ff87477..97a7295b 100644 --- a/java/src/generated/java/io/cucumber/messages/types/GlobalHookStarted.java +++ b/java/src/generated/java/io/cucumber/messages/types/TestRunHookStarted.java @@ -8,27 +8,27 @@ import static java.util.Objects.requireNonNull; /** - * Represents the GlobalHookStarted message in Cucumber's message protocol + * Represents the TestRunHookStarted message in Cucumber's message protocol * @see Github - Cucumber - Messages */ // Generated code @SuppressWarnings("unused") -public final class GlobalHookStarted { +public final class TestRunHookStarted { private final String id; private final String testRunStartedId; private final String hookId; private final Timestamp timestamp; - public GlobalHookStarted( + public TestRunHookStarted( String id, String testRunStartedId, String hookId, Timestamp timestamp ) { - this.id = requireNonNull(id, "GlobalHookStarted.id cannot be null"); - this.testRunStartedId = requireNonNull(testRunStartedId, "GlobalHookStarted.testRunStartedId cannot be null"); - this.hookId = requireNonNull(hookId, "GlobalHookStarted.hookId cannot be null"); - this.timestamp = requireNonNull(timestamp, "GlobalHookStarted.timestamp cannot be null"); + this.id = requireNonNull(id, "TestRunHookStarted.id cannot be null"); + this.testRunStartedId = requireNonNull(testRunStartedId, "TestRunHookStarted.testRunStartedId cannot be null"); + this.hookId = requireNonNull(hookId, "TestRunHookStarted.hookId cannot be null"); + this.timestamp = requireNonNull(timestamp, "TestRunHookStarted.timestamp cannot be null"); } /** @@ -60,7 +60,7 @@ public Timestamp getTimestamp() { public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - GlobalHookStarted that = (GlobalHookStarted) o; + TestRunHookStarted that = (TestRunHookStarted) o; return id.equals(that.id) && testRunStartedId.equals(that.testRunStartedId) && @@ -80,7 +80,7 @@ public int hashCode() { @Override public String toString() { - return "GlobalHookStarted{" + + return "TestRunHookStarted{" + "id=" + id + ", testRunStartedId=" + testRunStartedId + ", hookId=" + hookId + diff --git a/javascript/src/messages.ts b/javascript/src/messages.ts index 08e55678..e7d69174 100644 --- a/javascript/src/messages.ts +++ b/javascript/src/messages.ts @@ -80,11 +80,11 @@ export class Envelope { @Type(() => TestStepStarted) testStepStarted?: TestStepStarted - @Type(() => GlobalHookStarted) - globalHookStarted?: GlobalHookStarted + @Type(() => TestRunHookStarted) + testRunHookStarted?: TestRunHookStarted - @Type(() => GlobalHookFinished) - globalHookFinished?: GlobalHookFinished + @Type(() => TestRunHookFinished) + testRunHookFinished?: TestRunHookFinished @Type(() => UndefinedParameterType) undefinedParameterType?: UndefinedParameterType @@ -312,29 +312,6 @@ export class Tag { id: string = '' } -export class GlobalHookFinished { - - globalHookStartedId: string = '' - - @Type(() => TestStepResult) - result: TestStepResult = new TestStepResult() - - @Type(() => Timestamp) - timestamp: Timestamp = new Timestamp() -} - -export class GlobalHookStarted { - - id: string = '' - - testRunStartedId: string = '' - - hookId: string = '' - - @Type(() => Timestamp) - timestamp: Timestamp = new Timestamp() -} - export class Hook { id: string = '' @@ -649,6 +626,29 @@ export class TestRunFinished { testRunStartedId?: string } +export class TestRunHookFinished { + + testRunHookStartedId: string = '' + + @Type(() => TestStepResult) + result: TestStepResult = new TestStepResult() + + @Type(() => Timestamp) + timestamp: Timestamp = new Timestamp() +} + +export class TestRunHookStarted { + + id: string = '' + + testRunStartedId: string = '' + + hookId: string = '' + + @Type(() => Timestamp) + timestamp: Timestamp = new Timestamp() +} + export class TestRunStarted { @Type(() => Timestamp) diff --git a/jsonschema/Envelope.json b/jsonschema/Envelope.json index ccebf8d1..f96bb3bb 100644 --- a/jsonschema/Envelope.json +++ b/jsonschema/Envelope.json @@ -52,11 +52,11 @@ "testStepStarted": { "$ref": "./TestStepStarted.json" }, - "globalHookStarted": { - "$ref": "./GlobalHookStarted.json" + "testRunHookStarted": { + "$ref": "TestRunHookStarted.json" }, - "globalHookFinished": { - "$ref": "./GlobalHookFinished.json" + "testRunHookFinished": { + "$ref": "TestRunHookFinished.json" }, "undefinedParameterType": { "$ref": "./UndefinedParameterType.json" diff --git a/jsonschema/GlobalHookFinished.json b/jsonschema/TestRunHookFinished.json similarity index 81% rename from jsonschema/GlobalHookFinished.json rename to jsonschema/TestRunHookFinished.json index e3b4a62a..a0a85442 100644 --- a/jsonschema/GlobalHookFinished.json +++ b/jsonschema/TestRunHookFinished.json @@ -1,14 +1,14 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "GlobalHookFinished.json", + "$id": "TestRunHookFinished.json", "additionalProperties": false, "required": [ - "globalHookStartedId", + "testRunHookStartedId", "result", "timestamp" ], "properties": { - "globalHookStartedId": { + "testRunHookStartedId": { "description": "Identifier for the hook execution that has finished", "type": "string" }, diff --git a/jsonschema/GlobalHookStarted.json b/jsonschema/TestRunHookStarted.json similarity index 94% rename from jsonschema/GlobalHookStarted.json rename to jsonschema/TestRunHookStarted.json index 68b8561b..ff149699 100644 --- a/jsonschema/GlobalHookStarted.json +++ b/jsonschema/TestRunHookStarted.json @@ -1,6 +1,6 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "GlobalHookStarted.json", + "$id": "TestRunHookStarted.json", "additionalProperties": false, "required": [ "id", diff --git a/messages.md b/messages.md index e1c6112f..a54d85a1 100644 --- a/messages.md +++ b/messages.md @@ -44,8 +44,8 @@ will only have one of its fields set, which indicates the payload of the message | `testRunStarted` | [TestRunStarted](#testrunstarted) | no | | | `testStepFinished` | [TestStepFinished](#teststepfinished) | no | | | `testStepStarted` | [TestStepStarted](#teststepstarted) | no | | -| `globalHookStarted` | [GlobalHookStarted](#globalhookstarted) | no | | -| `globalHookFinished` | [GlobalHookFinished](#globalhookfinished) | no | | +| `testRunHookStarted` | [TestRunHookStarted](#testrunhookstarted) | no | | +| `testRunHookFinished` | [TestRunHookFinished](#testrunhookfinished) | no | | | `undefinedParameterType` | [UndefinedParameterType](#undefinedparametertype) | no | | ## Exception @@ -198,23 +198,6 @@ will only have one of its fields set, which indicates the payload of the message | `name` | string | yes | | | `id` | string | yes | | -## GlobalHookFinished - -| Field | Type | Required | Description | -| ----- | ---- | ----------- | ----------- | -| `globalHookStartedId` | string | yes | | -| `result` | [TestStepResult](#teststepresult) | yes | | -| `timestamp` | [Timestamp](#timestamp) | yes | | - -## GlobalHookStarted - -| Field | Type | Required | Description | -| ----- | ---- | ----------- | ----------- | -| `id` | string | yes | | -| `testRunStartedId` | string | yes | | -| `hookId` | string | yes | | -| `timestamp` | [Timestamp](#timestamp) | yes | | - ## Hook | Field | Type | Required | Description | @@ -462,6 +445,23 @@ will only have one of its fields set, which indicates the payload of the message | `exception` | [Exception](#exception) | no | | | `testRunStartedId` | string | no | | +## TestRunHookFinished + +| Field | Type | Required | Description | +| ----- | ---- | ----------- | ----------- | +| `testRunHookStartedId` | string | yes | | +| `result` | [TestStepResult](#teststepresult) | yes | | +| `timestamp` | [Timestamp](#timestamp) | yes | | + +## TestRunHookStarted + +| Field | Type | Required | Description | +| ----- | ---- | ----------- | ----------- | +| `id` | string | yes | | +| `testRunStartedId` | string | yes | | +| `hookId` | string | yes | | +| `timestamp` | [Timestamp](#timestamp) | yes | | + ## TestRunStarted | Field | Type | Required | Description | diff --git a/perl/lib/Cucumber/Messages.pm b/perl/lib/Cucumber/Messages.pm index 99822e76..5d008d90 100644 --- a/perl/lib/Cucumber/Messages.pm +++ b/perl/lib/Cucumber/Messages.pm @@ -345,8 +345,8 @@ my %types = ( test_run_started => 'Cucumber::Messages::TestRunStarted', test_step_finished => 'Cucumber::Messages::TestStepFinished', test_step_started => 'Cucumber::Messages::TestStepStarted', - global_hook_started => 'Cucumber::Messages::GlobalHookStarted', - global_hook_finished => 'Cucumber::Messages::GlobalHookFinished', + test_run_hook_started => 'Cucumber::Messages::TestRunHookStarted', + test_run_hook_finished => 'Cucumber::Messages::TestRunHookFinished', undefined_parameter_type => 'Cucumber::Messages::UndefinedParameterType', ); @@ -518,22 +518,22 @@ has test_step_started => ); -=head4 global_hook_started +=head4 test_run_hook_started =cut -has global_hook_started => +has test_run_hook_started => (is => 'ro', ); -=head4 global_hook_finished +=head4 test_run_hook_finished =cut -has global_hook_finished => +has test_run_hook_finished => (is => 'ro', ); @@ -1996,163 +1996,6 @@ has id => ); -} - -package Cucumber::Messages::GlobalHookFinished { - -=head2 Cucumber::Messages::GlobalHookFinished - -=head3 DESCRIPTION - -Represents the GlobalHookFinished message in Cucumber's -L. - - - -=head3 ATTRIBUTES - -=cut - -use Moo; -extends 'Cucumber::Messages::Message'; - -use Scalar::Util qw( blessed ); - -my %types = ( - global_hook_started_id => 'string', - result => 'Cucumber::Messages::TestStepResult', - timestamp => 'Cucumber::Messages::Timestamp', -); - -# This is a work-around for the fact that Moo doesn't have introspection -# and Perl doesn't have boolean values... -sub _types { - return \%types; -} - - - -=head4 global_hook_started_id - -Identifier for the hook execution that has finished -=cut - -has global_hook_started_id => - (is => 'ro', - required => 1, - default => sub { '' }, - ); - - -=head4 result - - -=cut - -has result => - (is => 'ro', - required => 1, - default => sub { Cucumber::Messages::TestStepResult->new() }, - ); - - -=head4 timestamp - - -=cut - -has timestamp => - (is => 'ro', - required => 1, - default => sub { Cucumber::Messages::Timestamp->new() }, - ); - - -} - -package Cucumber::Messages::GlobalHookStarted { - -=head2 Cucumber::Messages::GlobalHookStarted - -=head3 DESCRIPTION - -Represents the GlobalHookStarted message in Cucumber's -L. - - - -=head3 ATTRIBUTES - -=cut - -use Moo; -extends 'Cucumber::Messages::Message'; - -use Scalar::Util qw( blessed ); - -my %types = ( - id => 'string', - test_run_started_id => 'string', - hook_id => 'string', - timestamp => 'Cucumber::Messages::Timestamp', -); - -# This is a work-around for the fact that Moo doesn't have introspection -# and Perl doesn't have boolean values... -sub _types { - return \%types; -} - - - -=head4 id - -Unique identifier for this hook execution -=cut - -has id => - (is => 'ro', - required => 1, - default => sub { '' }, - ); - - -=head4 test_run_started_id - -Identifier for the test run that this hook execution belongs to -=cut - -has test_run_started_id => - (is => 'ro', - required => 1, - default => sub { '' }, - ); - - -=head4 hook_id - -Identifier for the hook that will be executed -=cut - -has hook_id => - (is => 'ro', - required => 1, - default => sub { '' }, - ); - - -=head4 timestamp - - -=cut - -has timestamp => - (is => 'ro', - required => 1, - default => sub { Cucumber::Messages::Timestamp->new() }, - ); - - } package Cucumber::Messages::Hook { @@ -4452,6 +4295,163 @@ has test_run_started_id => ); +} + +package Cucumber::Messages::TestRunHookFinished { + +=head2 Cucumber::Messages::TestRunHookFinished + +=head3 DESCRIPTION + +Represents the TestRunHookFinished message in Cucumber's +L. + + + +=head3 ATTRIBUTES + +=cut + +use Moo; +extends 'Cucumber::Messages::Message'; + +use Scalar::Util qw( blessed ); + +my %types = ( + test_run_hook_started_id => 'string', + result => 'Cucumber::Messages::TestStepResult', + timestamp => 'Cucumber::Messages::Timestamp', +); + +# This is a work-around for the fact that Moo doesn't have introspection +# and Perl doesn't have boolean values... +sub _types { + return \%types; +} + + + +=head4 test_run_hook_started_id + +Identifier for the hook execution that has finished +=cut + +has test_run_hook_started_id => + (is => 'ro', + required => 1, + default => sub { '' }, + ); + + +=head4 result + + +=cut + +has result => + (is => 'ro', + required => 1, + default => sub { Cucumber::Messages::TestStepResult->new() }, + ); + + +=head4 timestamp + + +=cut + +has timestamp => + (is => 'ro', + required => 1, + default => sub { Cucumber::Messages::Timestamp->new() }, + ); + + +} + +package Cucumber::Messages::TestRunHookStarted { + +=head2 Cucumber::Messages::TestRunHookStarted + +=head3 DESCRIPTION + +Represents the TestRunHookStarted message in Cucumber's +L. + + + +=head3 ATTRIBUTES + +=cut + +use Moo; +extends 'Cucumber::Messages::Message'; + +use Scalar::Util qw( blessed ); + +my %types = ( + id => 'string', + test_run_started_id => 'string', + hook_id => 'string', + timestamp => 'Cucumber::Messages::Timestamp', +); + +# This is a work-around for the fact that Moo doesn't have introspection +# and Perl doesn't have boolean values... +sub _types { + return \%types; +} + + + +=head4 id + +Unique identifier for this hook execution +=cut + +has id => + (is => 'ro', + required => 1, + default => sub { '' }, + ); + + +=head4 test_run_started_id + +Identifier for the test run that this hook execution belongs to +=cut + +has test_run_started_id => + (is => 'ro', + required => 1, + default => sub { '' }, + ); + + +=head4 hook_id + +Identifier for the hook that will be executed +=cut + +has hook_id => + (is => 'ro', + required => 1, + default => sub { '' }, + ); + + +=head4 timestamp + + +=cut + +has timestamp => + (is => 'ro', + required => 1, + default => sub { Cucumber::Messages::Timestamp->new() }, + ); + + } package Cucumber::Messages::TestRunStarted { diff --git a/php/src-generated/Envelope.php b/php/src-generated/Envelope.php index ea585704..acf6639c 100644 --- a/php/src-generated/Envelope.php +++ b/php/src-generated/Envelope.php @@ -46,8 +46,8 @@ public function __construct( public readonly ?TestRunStarted $testRunStarted = null, public readonly ?TestStepFinished $testStepFinished = null, public readonly ?TestStepStarted $testStepStarted = null, - public readonly ?GlobalHookStarted $globalHookStarted = null, - public readonly ?GlobalHookFinished $globalHookFinished = null, + public readonly ?TestRunHookStarted $testRunHookStarted = null, + public readonly ?TestRunHookFinished $testRunHookFinished = null, public readonly ?UndefinedParameterType $undefinedParameterType = null, ) { } @@ -75,8 +75,8 @@ public static function fromArray(array $arr): self self::ensureTestRunStarted($arr); self::ensureTestStepFinished($arr); self::ensureTestStepStarted($arr); - self::ensureGlobalHookStarted($arr); - self::ensureGlobalHookFinished($arr); + self::ensureTestRunHookStarted($arr); + self::ensureTestRunHookFinished($arr); self::ensureUndefinedParameterType($arr); return new self( @@ -96,8 +96,8 @@ public static function fromArray(array $arr): self isset($arr['testRunStarted']) ? TestRunStarted::fromArray($arr['testRunStarted']) : null, isset($arr['testStepFinished']) ? TestStepFinished::fromArray($arr['testStepFinished']) : null, isset($arr['testStepStarted']) ? TestStepStarted::fromArray($arr['testStepStarted']) : null, - isset($arr['globalHookStarted']) ? GlobalHookStarted::fromArray($arr['globalHookStarted']) : null, - isset($arr['globalHookFinished']) ? GlobalHookFinished::fromArray($arr['globalHookFinished']) : null, + isset($arr['testRunHookStarted']) ? TestRunHookStarted::fromArray($arr['testRunHookStarted']) : null, + isset($arr['testRunHookFinished']) ? TestRunHookFinished::fromArray($arr['testRunHookFinished']) : null, isset($arr['undefinedParameterType']) ? UndefinedParameterType::fromArray($arr['undefinedParameterType']) : null, ); } @@ -263,22 +263,22 @@ private static function ensureTestStepStarted(array $arr): void } /** - * @psalm-assert array{globalHookStarted?: array} $arr + * @psalm-assert array{testRunHookStarted?: array} $arr */ - private static function ensureGlobalHookStarted(array $arr): void + private static function ensureTestRunHookStarted(array $arr): void { - if (array_key_exists('globalHookStarted', $arr) && !is_array($arr['globalHookStarted'])) { - throw new SchemaViolationException('Property \'globalHookStarted\' was not array'); + if (array_key_exists('testRunHookStarted', $arr) && !is_array($arr['testRunHookStarted'])) { + throw new SchemaViolationException('Property \'testRunHookStarted\' was not array'); } } /** - * @psalm-assert array{globalHookFinished?: array} $arr + * @psalm-assert array{testRunHookFinished?: array} $arr */ - private static function ensureGlobalHookFinished(array $arr): void + private static function ensureTestRunHookFinished(array $arr): void { - if (array_key_exists('globalHookFinished', $arr) && !is_array($arr['globalHookFinished'])) { - throw new SchemaViolationException('Property \'globalHookFinished\' was not array'); + if (array_key_exists('testRunHookFinished', $arr) && !is_array($arr['testRunHookFinished'])) { + throw new SchemaViolationException('Property \'testRunHookFinished\' was not array'); } } diff --git a/php/src-generated/GlobalHookFinished.php b/php/src-generated/TestRunHookFinished.php similarity index 69% rename from php/src-generated/GlobalHookFinished.php rename to php/src-generated/TestRunHookFinished.php index 65b73bab..58df204e 100644 --- a/php/src-generated/GlobalHookFinished.php +++ b/php/src-generated/TestRunHookFinished.php @@ -12,16 +12,16 @@ use Cucumber\Messages\DecodingException\SchemaViolationException; /** - * Represents the GlobalHookFinished message in Cucumber's message protocol + * Represents the TestRunHookFinished message in Cucumber's message protocol * @see https://github.com/cucumber/messages * */ -final class GlobalHookFinished implements JsonSerializable +final class TestRunHookFinished implements JsonSerializable { use JsonEncodingTrait; /** - * Construct the GlobalHookFinished with all properties + * Construct the TestRunHookFinished with all properties * */ public function __construct( @@ -29,7 +29,7 @@ public function __construct( /** * Identifier for the hook execution that has finished */ - public readonly string $globalHookStartedId = '', + public readonly string $testRunHookStartedId = '', public readonly TestStepResult $result = new TestStepResult(), public readonly Timestamp $timestamp = new Timestamp(), ) { @@ -42,27 +42,27 @@ public function __construct( */ public static function fromArray(array $arr): self { - self::ensureGlobalHookStartedId($arr); + self::ensureTestRunHookStartedId($arr); self::ensureResult($arr); self::ensureTimestamp($arr); return new self( - (string) $arr['globalHookStartedId'], + (string) $arr['testRunHookStartedId'], TestStepResult::fromArray($arr['result']), Timestamp::fromArray($arr['timestamp']), ); } /** - * @psalm-assert array{globalHookStartedId: string|int|bool} $arr + * @psalm-assert array{testRunHookStartedId: string|int|bool} $arr */ - private static function ensureGlobalHookStartedId(array $arr): void + private static function ensureTestRunHookStartedId(array $arr): void { - if (!array_key_exists('globalHookStartedId', $arr)) { - throw new SchemaViolationException('Property \'globalHookStartedId\' is required but was not found'); + if (!array_key_exists('testRunHookStartedId', $arr)) { + throw new SchemaViolationException('Property \'testRunHookStartedId\' is required but was not found'); } - if (array_key_exists('globalHookStartedId', $arr) && is_array($arr['globalHookStartedId'])) { - throw new SchemaViolationException('Property \'globalHookStartedId\' was array'); + if (array_key_exists('testRunHookStartedId', $arr) && is_array($arr['testRunHookStartedId'])) { + throw new SchemaViolationException('Property \'testRunHookStartedId\' was array'); } } diff --git a/php/src-generated/GlobalHookStarted.php b/php/src-generated/TestRunHookStarted.php similarity index 94% rename from php/src-generated/GlobalHookStarted.php rename to php/src-generated/TestRunHookStarted.php index 3179d654..5eeb5fe8 100644 --- a/php/src-generated/GlobalHookStarted.php +++ b/php/src-generated/TestRunHookStarted.php @@ -12,16 +12,16 @@ use Cucumber\Messages\DecodingException\SchemaViolationException; /** - * Represents the GlobalHookStarted message in Cucumber's message protocol + * Represents the TestRunHookStarted message in Cucumber's message protocol * @see https://github.com/cucumber/messages * */ -final class GlobalHookStarted implements JsonSerializable +final class TestRunHookStarted implements JsonSerializable { use JsonEncodingTrait; /** - * Construct the GlobalHookStarted with all properties + * Construct the TestRunHookStarted with all properties * */ public function __construct( diff --git a/ruby/lib/cucumber/messages/envelope.rb b/ruby/lib/cucumber/messages/envelope.rb index 5c381a36..e7ddc627 100644 --- a/ruby/lib/cucumber/messages/envelope.rb +++ b/ruby/lib/cucumber/messages/envelope.rb @@ -48,9 +48,9 @@ class Envelope < Message attr_reader :test_step_started - attr_reader :global_hook_started + attr_reader :test_run_hook_started - attr_reader :global_hook_finished + attr_reader :test_run_hook_finished attr_reader :undefined_parameter_type @@ -71,8 +71,8 @@ def initialize( test_run_started: nil, test_step_finished: nil, test_step_started: nil, - global_hook_started: nil, - global_hook_finished: nil, + test_run_hook_started: nil, + test_run_hook_finished: nil, undefined_parameter_type: nil ) @attachment = attachment @@ -91,8 +91,8 @@ def initialize( @test_run_started = test_run_started @test_step_finished = test_step_finished @test_step_started = test_step_started - @global_hook_started = global_hook_started - @global_hook_finished = global_hook_finished + @test_run_hook_started = test_run_hook_started + @test_run_hook_finished = test_run_hook_finished @undefined_parameter_type = undefined_parameter_type super() end @@ -124,8 +124,8 @@ def self.from_h(hash) test_run_started: TestRunStarted.from_h(hash[:testRunStarted]), test_step_finished: TestStepFinished.from_h(hash[:testStepFinished]), test_step_started: TestStepStarted.from_h(hash[:testStepStarted]), - global_hook_started: GlobalHookStarted.from_h(hash[:globalHookStarted]), - global_hook_finished: GlobalHookFinished.from_h(hash[:globalHookFinished]), + test_run_hook_started: TestRunHookStarted.from_h(hash[:testRunHookStarted]), + test_run_hook_finished: TestRunHookFinished.from_h(hash[:testRunHookFinished]), undefined_parameter_type: UndefinedParameterType.from_h(hash[:undefinedParameterType]) ) end diff --git a/ruby/lib/cucumber/messages/global_hook_finished.rb b/ruby/lib/cucumber/messages/test_run_hook_finished.rb similarity index 61% rename from ruby/lib/cucumber/messages/global_hook_finished.rb rename to ruby/lib/cucumber/messages/test_run_hook_finished.rb index 18f835c9..4dfbaf95 100644 --- a/ruby/lib/cucumber/messages/global_hook_finished.rb +++ b/ruby/lib/cucumber/messages/test_run_hook_finished.rb @@ -4,42 +4,42 @@ module Cucumber module Messages ## - # Represents the GlobalHookFinished message in Cucumber's {message protocol}[https://github.com/cucumber/messages]. + # Represents the TestRunHookFinished message in Cucumber's {message protocol}[https://github.com/cucumber/messages]. ## ## - class GlobalHookFinished < Message + class TestRunHookFinished < Message ## # Identifier for the hook execution that has finished ## - attr_reader :global_hook_started_id + attr_reader :test_run_hook_started_id attr_reader :result attr_reader :timestamp def initialize( - global_hook_started_id: '', + test_run_hook_started_id: '', result: TestStepResult.new, timestamp: Timestamp.new ) - @global_hook_started_id = global_hook_started_id + @test_run_hook_started_id = test_run_hook_started_id @result = result @timestamp = timestamp super() end ## - # Returns a new GlobalHookFinished from the given hash. + # Returns a new TestRunHookFinished from the given hash. # If the hash keys are camelCased, they are properly assigned to the # corresponding snake_cased attributes. # - # Cucumber::Messages::GlobalHookFinished.from_h(some_hash) # => # + # Cucumber::Messages::TestRunHookFinished.from_h(some_hash) # => # ## def self.from_h(hash) return nil if hash.nil? new( - global_hook_started_id: hash[:globalHookStartedId], + test_run_hook_started_id: hash[:testRunHookStartedId], result: TestStepResult.from_h(hash[:result]), timestamp: Timestamp.from_h(hash[:timestamp]) ) diff --git a/ruby/lib/cucumber/messages/global_hook_started.rb b/ruby/lib/cucumber/messages/test_run_hook_started.rb similarity index 78% rename from ruby/lib/cucumber/messages/global_hook_started.rb rename to ruby/lib/cucumber/messages/test_run_hook_started.rb index 0ef82d03..e193030d 100644 --- a/ruby/lib/cucumber/messages/global_hook_started.rb +++ b/ruby/lib/cucumber/messages/test_run_hook_started.rb @@ -4,10 +4,10 @@ module Cucumber module Messages ## - # Represents the GlobalHookStarted message in Cucumber's {message protocol}[https://github.com/cucumber/messages]. + # Represents the TestRunHookStarted message in Cucumber's {message protocol}[https://github.com/cucumber/messages]. ## ## - class GlobalHookStarted < Message + class TestRunHookStarted < Message ## # Unique identifier for this hook execution ## @@ -39,11 +39,11 @@ def initialize( end ## - # Returns a new GlobalHookStarted from the given hash. + # Returns a new TestRunHookStarted from the given hash. # If the hash keys are camelCased, they are properly assigned to the # corresponding snake_cased attributes. # - # Cucumber::Messages::GlobalHookStarted.from_h(some_hash) # => # + # Cucumber::Messages::TestRunHookStarted.from_h(some_hash) # => # ## def self.from_h(hash) return nil if hash.nil? From 3fd35b9647b32628546753c3ed3711a63379fd90 Mon Sep 17 00:00:00 2001 From: David Goss Date: Fri, 20 Sep 2024 20:18:30 +0100 Subject: [PATCH 11/18] fix bad merge on CHANGELOG.md --- CHANGELOG.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3abf45f0..0b54e0db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +### Added +- BREAKING CHANGE: Add `id` property to `TestRunStarted`, optionally reference in `Attachment`, TestCase` and `TestRunFinished` ([#102](https://github.com/cucumber/messages/pull/102)) +- Add new `TestRunHookStarted` and `TestRunHookFinished` messages ([#102](https://github.com/cucumber/messages/pull/102)) + ### Fixed - [Dotnet] Fixed code generation for types that accept List as parameters. Constructors were not properly handling null input. ([#249](https://github.com/cucumber/messages/pull/249) [clrudolphi]) - Moved contents of the description of the StepDefinitionIds field from the StepMatchArgumentsList field where it had been mistakenly placed. ([#252](https://github.com/cucumber/messages/pull/252) [clrudolphi]) @@ -15,13 +19,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [26.0.0] - 2024-08-15 ### Added -<<<<<<< HEAD -- BREAKING CHANGE: Add `id` property to `TestRunStarted`, optionally reference in `Attachment`, TestCase` and `TestRunFinished` ([#102](https://github.com/cucumber/messages/pull/102)) -- Add new `TestRunHookStarted` and `TestRunHookFinished` messages ([#102](https://github.com/cucumber/messages/pull/102)) -- [Dotnet] Added support classes aligned with what is provided for the Java implementation (https://github.com/cucumber/messages/pull/233 [clrudolphi](https://github.com/clrudolphi)) -======= - [Dotnet] Added support classes aligned with what is provided for the Java implementation ([#233](https://github.com/cucumber/messages/pull/233) [clrudolphi](https://github.com/clrudolphi)) ->>>>>>> main ### Changed - **Internal breaking change** The code generation has undergone a large refactor (No visible changes expected). All new code From ffe2924ea01c2c98934046130c505ca94a3f363d Mon Sep 17 00:00:00 2001 From: David Goss Date: Fri, 20 Sep 2024 20:20:56 +0100 Subject: [PATCH 12/18] remove errant cpp files --- .../messages/global_hook_finished.cpp | 52 ------------------ .../cucumber/messages/global_hook_started.cpp | 54 ------------------- 2 files changed, 106 deletions(-) delete mode 100644 cpp/src/lib/messages/cucumber/messages/global_hook_finished.cpp delete mode 100644 cpp/src/lib/messages/cucumber/messages/global_hook_started.cpp diff --git a/cpp/src/lib/messages/cucumber/messages/global_hook_finished.cpp b/cpp/src/lib/messages/cucumber/messages/global_hook_finished.cpp deleted file mode 100644 index 5fd77aba..00000000 --- a/cpp/src/lib/messages/cucumber/messages/global_hook_finished.cpp +++ /dev/null @@ -1,52 +0,0 @@ -#include - -#include -#include - -namespace cucumber::messages { - -std::string -global_hook_finished::to_string() const -{ - std::ostringstream oss; - - cucumber::messages::to_string(oss, "global_hook_started_id=", global_hook_started_id); - cucumber::messages::to_string(oss, ", result=", result); - cucumber::messages::to_string(oss, ", timestamp=", timestamp); - - return oss.str(); -} - -void -global_hook_finished::to_json(json& j) const -{ - cucumber::messages::to_json(j, camelize("global_hook_started_id"), global_hook_started_id); - cucumber::messages::to_json(j, camelize("result"), result); - cucumber::messages::to_json(j, camelize("timestamp"), timestamp); -} - -std::string -global_hook_finished::to_json() const -{ - std::ostringstream oss; - json j; - - to_json(j); - - oss << j; - - return oss.str(); -} - -std::ostream& -operator<<(std::ostream& os, const global_hook_finished& msg) -{ - os << msg.to_string(); - - return os; -} - -void to_json(json& j, const global_hook_finished& m) -{ m.to_json(j); } - -} diff --git a/cpp/src/lib/messages/cucumber/messages/global_hook_started.cpp b/cpp/src/lib/messages/cucumber/messages/global_hook_started.cpp deleted file mode 100644 index bb5a734d..00000000 --- a/cpp/src/lib/messages/cucumber/messages/global_hook_started.cpp +++ /dev/null @@ -1,54 +0,0 @@ -#include - -#include -#include - -namespace cucumber::messages { - -std::string -global_hook_started::to_string() const -{ - std::ostringstream oss; - - cucumber::messages::to_string(oss, "id=", id); - cucumber::messages::to_string(oss, ", test_run_started_id=", test_run_started_id); - cucumber::messages::to_string(oss, ", hook_id=", hook_id); - cucumber::messages::to_string(oss, ", timestamp=", timestamp); - - return oss.str(); -} - -void -global_hook_started::to_json(json& j) const -{ - cucumber::messages::to_json(j, camelize("id"), id); - cucumber::messages::to_json(j, camelize("test_run_started_id"), test_run_started_id); - cucumber::messages::to_json(j, camelize("hook_id"), hook_id); - cucumber::messages::to_json(j, camelize("timestamp"), timestamp); -} - -std::string -global_hook_started::to_json() const -{ - std::ostringstream oss; - json j; - - to_json(j); - - oss << j; - - return oss.str(); -} - -std::ostream& -operator<<(std::ostream& os, const global_hook_started& msg) -{ - os << msg.to_string(); - - return os; -} - -void to_json(json& j, const global_hook_started& m) -{ m.to_json(j); } - -} From f7ca9f48e0e4cabbc7c374c0a5b7d3da140126a8 Mon Sep 17 00:00:00 2001 From: David Goss Date: Fri, 20 Sep 2024 20:26:27 +0100 Subject: [PATCH 13/18] add type enum to Hook --- .../messages/cucumber/messages/hook.hpp | 2 + .../messages/cucumber/messages/hook_type.hpp | 23 ++++++++++ .../lib/messages/cucumber/messages/hook.cpp | 2 + .../messages/cucumber/messages/hook_type.cpp | 33 +++++++++++++++ dotnet/Cucumber.Messages/generated/Hook.cs | 10 ++++- .../Cucumber.Messages/generated/HookType.cs | 40 ++++++++++++++++++ go/messages.go | 31 ++++++++++++++ .../java/io/cucumber/messages/types/Hook.java | 16 +++++-- .../io/cucumber/messages/types/HookType.java | 42 +++++++++++++++++++ javascript/src/messages.ts | 11 +++++ jsonschema/Hook.json | 11 +++++ messages.md | 13 ++++++ perl/lib/Cucumber/Messages.pm | 40 ++++++++++++++++++ php/src-generated/Hook.php | 13 ++++++ php/src-generated/Hook/Type.php | 19 +++++++++ ruby/lib/cucumber/messages/hook.rb | 9 +++- ruby/lib/cucumber/messages/hook_type.rb | 15 +++++++ 17 files changed, 323 insertions(+), 7 deletions(-) create mode 100644 cpp/include/messages/cucumber/messages/hook_type.hpp create mode 100644 cpp/src/lib/messages/cucumber/messages/hook_type.cpp create mode 100644 dotnet/Cucumber.Messages/generated/HookType.cs create mode 100644 java/src/generated/java/io/cucumber/messages/types/HookType.java create mode 100644 php/src-generated/Hook/Type.php create mode 100644 ruby/lib/cucumber/messages/hook_type.rb diff --git a/cpp/include/messages/cucumber/messages/hook.hpp b/cpp/include/messages/cucumber/messages/hook.hpp index 8a9c1f7d..123665b2 100644 --- a/cpp/include/messages/cucumber/messages/hook.hpp +++ b/cpp/include/messages/cucumber/messages/hook.hpp @@ -7,6 +7,7 @@ #include #include +#include namespace cucumber::messages { @@ -24,6 +25,7 @@ struct hook std::optional name; cucumber::messages::source_reference source_reference; std::optional tag_expression; + std::optional type; std::string to_string() const; diff --git a/cpp/include/messages/cucumber/messages/hook_type.hpp b/cpp/include/messages/cucumber/messages/hook_type.hpp new file mode 100644 index 00000000..a69e5493 --- /dev/null +++ b/cpp/include/messages/cucumber/messages/hook_type.hpp @@ -0,0 +1,23 @@ +#pragma once + +#include + +namespace cucumber::messages { + +enum class hook_type +{ + BEFORE_TEST_RUN, + AFTER_TEST_RUN, + BEFORE_TEST_CASE, + AFTER_TEST_CASE, + BEFORE_TEST_STEP, + AFTER_TEST_STEP +}; + +std::string_view +to_string(hook_type v); + +std::ostream& +operator<<(std::ostream& os, hook_type v); + +} diff --git a/cpp/src/lib/messages/cucumber/messages/hook.cpp b/cpp/src/lib/messages/cucumber/messages/hook.cpp index 7566258a..bfd5e186 100644 --- a/cpp/src/lib/messages/cucumber/messages/hook.cpp +++ b/cpp/src/lib/messages/cucumber/messages/hook.cpp @@ -14,6 +14,7 @@ hook::to_string() const cucumber::messages::to_string(oss, ", name=", name); cucumber::messages::to_string(oss, ", source_reference=", source_reference); cucumber::messages::to_string(oss, ", tag_expression=", tag_expression); + cucumber::messages::to_string(oss, ", type=", type); return oss.str(); } @@ -25,6 +26,7 @@ hook::to_json(json& j) const cucumber::messages::to_json(j, camelize("name"), name); cucumber::messages::to_json(j, camelize("source_reference"), source_reference); cucumber::messages::to_json(j, camelize("tag_expression"), tag_expression); + cucumber::messages::to_json(j, camelize("type"), type); } std::string diff --git a/cpp/src/lib/messages/cucumber/messages/hook_type.cpp b/cpp/src/lib/messages/cucumber/messages/hook_type.cpp new file mode 100644 index 00000000..1f9c0aa4 --- /dev/null +++ b/cpp/src/lib/messages/cucumber/messages/hook_type.cpp @@ -0,0 +1,33 @@ +#include +#include + +#include + +namespace cucumber::messages { + +std::string_view +to_string(hook_type v) +{ + using map_type = std::unordered_map; + + static const map_type m = { + { hook_type::BEFORE_TEST_RUN, "BEFORE_TEST_RUN" }, + { hook_type::AFTER_TEST_RUN, "AFTER_TEST_RUN" }, + { hook_type::BEFORE_TEST_CASE, "BEFORE_TEST_CASE" }, + { hook_type::AFTER_TEST_CASE, "AFTER_TEST_CASE" }, + { hook_type::BEFORE_TEST_STEP, "BEFORE_TEST_STEP" }, + { hook_type::AFTER_TEST_STEP, "AFTER_TEST_STEP" } + }; + + return m.at(v); +} + +std::ostream& +operator<<(std::ostream& os, hook_type v) +{ + os << to_string(v); + + return os; +} + +} diff --git a/dotnet/Cucumber.Messages/generated/Hook.cs b/dotnet/Cucumber.Messages/generated/Hook.cs index 48249f1e..eaca150b 100644 --- a/dotnet/Cucumber.Messages/generated/Hook.cs +++ b/dotnet/Cucumber.Messages/generated/Hook.cs @@ -20,13 +20,15 @@ public sealed class Hook public string Name { get; private set; } public SourceReference SourceReference { get; private set; } public string TagExpression { get; private set; } + public HookType Type { get; private set; } public Hook( string id, string name, SourceReference sourceReference, - string tagExpression + string tagExpression, + HookType type ) { RequireNonNull(id, "Id", "Hook.Id cannot be null"); @@ -35,6 +37,7 @@ string tagExpression RequireNonNull(sourceReference, "SourceReference", "Hook.SourceReference cannot be null"); this.SourceReference = sourceReference; this.TagExpression = tagExpression; + this.Type = type; } public override bool Equals(Object o) @@ -46,7 +49,8 @@ public override bool Equals(Object o) Id.Equals(that.Id) && Object.Equals(Name, that.Name) && SourceReference.Equals(that.SourceReference) && - Object.Equals(TagExpression, that.TagExpression); + Object.Equals(TagExpression, that.TagExpression) && + Object.Equals(Type, that.Type); } public override int GetHashCode() @@ -60,6 +64,7 @@ public override int GetHashCode() hash = hash * 31 + SourceReference.GetHashCode(); if (TagExpression != null) hash = hash * 31 + TagExpression.GetHashCode(); + hash = hash * 31 + Type.GetHashCode(); return hash; } @@ -70,6 +75,7 @@ public override string ToString() ", name=" + Name + ", sourceReference=" + SourceReference + ", tagExpression=" + TagExpression + + ", type=" + Type + '}'; } diff --git a/dotnet/Cucumber.Messages/generated/HookType.cs b/dotnet/Cucumber.Messages/generated/HookType.cs new file mode 100644 index 00000000..ebc0e22a --- /dev/null +++ b/dotnet/Cucumber.Messages/generated/HookType.cs @@ -0,0 +1,40 @@ +using System; +using System.ComponentModel; +using System.Reflection; + +namespace Io.Cucumber.Messages.Types; + +// ------------------------------------------------------------------------------ +// This code was generated based on the Cucumber JSON schema +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// ------------------------------------------------------------------------------ + +public enum HookType { + + [Description("BEFORE_TEST_RUN")] + BEFORE_TEST_RUN, + + [Description("AFTER_TEST_RUN")] + AFTER_TEST_RUN, + + [Description("BEFORE_TEST_CASE")] + BEFORE_TEST_CASE, + + [Description("AFTER_TEST_CASE")] + AFTER_TEST_CASE, + + [Description("BEFORE_TEST_STEP")] + BEFORE_TEST_STEP, + + [Description("AFTER_TEST_STEP")] + AFTER_TEST_STEP +} + +public static class HookTypeExtensions +{ + public static string Value(this HookType v) { + var attribute = v.GetType().GetField(v.ToString()).GetCustomAttribute(); + return attribute == null ? v.ToString() : attribute.Description; + } +} diff --git a/go/messages.go b/go/messages.go index 4bf3d7a1..eaba8e4b 100644 --- a/go/messages.go +++ b/go/messages.go @@ -162,6 +162,7 @@ type Hook struct { Name string `json:"name,omitempty"` SourceReference *SourceReference `json:"sourceReference"` TagExpression string `json:"tagExpression,omitempty"` + Type HookType `json:"type,omitempty"` } type Location struct { @@ -410,6 +411,36 @@ func (e AttachmentContentEncoding) String() string { } } +type HookType string + +const ( + HookType_BEFORE_TEST_RUN HookType = "BEFORE_TEST_RUN" + HookType_AFTER_TEST_RUN HookType = "AFTER_TEST_RUN" + HookType_BEFORE_TEST_CASE HookType = "BEFORE_TEST_CASE" + HookType_AFTER_TEST_CASE HookType = "AFTER_TEST_CASE" + HookType_BEFORE_TEST_STEP HookType = "BEFORE_TEST_STEP" + HookType_AFTER_TEST_STEP HookType = "AFTER_TEST_STEP" +) + +func (e HookType) String() string { + switch e { + case HookType_BEFORE_TEST_RUN: + return "BEFORE_TEST_RUN" + case HookType_AFTER_TEST_RUN: + return "AFTER_TEST_RUN" + case HookType_BEFORE_TEST_CASE: + return "BEFORE_TEST_CASE" + case HookType_AFTER_TEST_CASE: + return "AFTER_TEST_CASE" + case HookType_BEFORE_TEST_STEP: + return "BEFORE_TEST_STEP" + case HookType_AFTER_TEST_STEP: + return "AFTER_TEST_STEP" + default: + panic("Bad enum value for HookType") + } +} + type PickleStepType string const ( diff --git a/java/src/generated/java/io/cucumber/messages/types/Hook.java b/java/src/generated/java/io/cucumber/messages/types/Hook.java index f8ea3331..3527d566 100644 --- a/java/src/generated/java/io/cucumber/messages/types/Hook.java +++ b/java/src/generated/java/io/cucumber/messages/types/Hook.java @@ -18,17 +18,20 @@ public final class Hook { private final String name; private final SourceReference sourceReference; private final String tagExpression; + private final HookType type; public Hook( String id, String name, SourceReference sourceReference, - String tagExpression + String tagExpression, + HookType type ) { this.id = requireNonNull(id, "Hook.id cannot be null"); this.name = name; this.sourceReference = requireNonNull(sourceReference, "Hook.sourceReference cannot be null"); this.tagExpression = tagExpression; + this.type = type; } public String getId() { @@ -47,6 +50,10 @@ public Optional getTagExpression() { return Optional.ofNullable(tagExpression); } + public Optional getType() { + return Optional.ofNullable(type); + } + @Override public boolean equals(Object o) { if (this == o) return true; @@ -56,7 +63,8 @@ public boolean equals(Object o) { id.equals(that.id) && Objects.equals(name, that.name) && sourceReference.equals(that.sourceReference) && - Objects.equals(tagExpression, that.tagExpression); + Objects.equals(tagExpression, that.tagExpression) && + Objects.equals(type, that.type); } @Override @@ -65,7 +73,8 @@ public int hashCode() { id, name, sourceReference, - tagExpression + tagExpression, + type ); } @@ -76,6 +85,7 @@ public String toString() { ", name=" + name + ", sourceReference=" + sourceReference + ", tagExpression=" + tagExpression + + ", type=" + type + '}'; } } diff --git a/java/src/generated/java/io/cucumber/messages/types/HookType.java b/java/src/generated/java/io/cucumber/messages/types/HookType.java new file mode 100644 index 00000000..0b66ca3a --- /dev/null +++ b/java/src/generated/java/io/cucumber/messages/types/HookType.java @@ -0,0 +1,42 @@ +package io.cucumber.messages.types; + +// Generated code +@SuppressWarnings("unused") +public enum HookType { + + BEFORE_TEST_RUN("BEFORE_TEST_RUN"), + + AFTER_TEST_RUN("AFTER_TEST_RUN"), + + BEFORE_TEST_CASE("BEFORE_TEST_CASE"), + + AFTER_TEST_CASE("AFTER_TEST_CASE"), + + BEFORE_TEST_STEP("BEFORE_TEST_STEP"), + + AFTER_TEST_STEP("AFTER_TEST_STEP"); + + private final String value; + + HookType(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + public String value() { + return this.value; + } + + public static HookType fromValue(String value) { + for (HookType v : values()) { + if (v.value.equals(value)) { + return v; + } + } + throw new IllegalArgumentException(value); + } +} diff --git a/javascript/src/messages.ts b/javascript/src/messages.ts index e7d69174..86e8abe0 100644 --- a/javascript/src/messages.ts +++ b/javascript/src/messages.ts @@ -322,6 +322,8 @@ export class Hook { sourceReference: SourceReference = new SourceReference() tagExpression?: string + + type?: HookType } export class Location { @@ -712,6 +714,15 @@ export enum AttachmentContentEncoding { BASE64 = 'BASE64', } +export enum HookType { + BEFORE_TEST_RUN = 'BEFORE_TEST_RUN', + AFTER_TEST_RUN = 'AFTER_TEST_RUN', + BEFORE_TEST_CASE = 'BEFORE_TEST_CASE', + AFTER_TEST_CASE = 'AFTER_TEST_CASE', + BEFORE_TEST_STEP = 'BEFORE_TEST_STEP', + AFTER_TEST_STEP = 'AFTER_TEST_STEP', +} + export enum PickleStepType { UNKNOWN = 'Unknown', CONTEXT = 'Context', diff --git a/jsonschema/Hook.json b/jsonschema/Hook.json index 6e64289b..5bbaf9ff 100644 --- a/jsonschema/Hook.json +++ b/jsonschema/Hook.json @@ -18,6 +18,17 @@ }, "tagExpression": { "type": "string" + }, + "type": { + "type": "string", + "enum": [ + "BEFORE_TEST_RUN", + "AFTER_TEST_RUN", + "BEFORE_TEST_CASE", + "AFTER_TEST_CASE", + "BEFORE_TEST_STEP", + "AFTER_TEST_STEP" + ] } }, "type": "object" diff --git a/messages.md b/messages.md index a54d85a1..a878324c 100644 --- a/messages.md +++ b/messages.md @@ -206,6 +206,7 @@ will only have one of its fields set, which indicates the payload of the message | `name` | string | no | | | `sourceReference` | [SourceReference](#sourcereference) | yes | | | `tagExpression` | string | no | | +| `type` | [HookType](#hooktype) | no | | ## Location @@ -517,6 +518,18 @@ One of the following: * `"BASE64"` +## HookType + +One of the following: + +* `"BEFORE_TEST_RUN"` +* `"AFTER_TEST_RUN"` +* `"BEFORE_TEST_CASE"` +* `"AFTER_TEST_CASE"` +* `"BEFORE_TEST_STEP"` +* `"AFTER_TEST_STEP"` + + ## PickleStepType One of the following: diff --git a/perl/lib/Cucumber/Messages.pm b/perl/lib/Cucumber/Messages.pm index ab9bcbe3..8996b695 100644 --- a/perl/lib/Cucumber/Messages.pm +++ b/perl/lib/Cucumber/Messages.pm @@ -2023,6 +2023,7 @@ my %types = ( name => 'string', source_reference => 'Cucumber::Messages::SourceReference', tag_expression => 'string', + type => '', ); # This is a work-around for the fact that Moo doesn't have introspection @@ -2077,6 +2078,45 @@ has tag_expression => ); +=head4 type + + + +Available constants for valid values of this field: + +=over + +=item * TYPE_BEFORE_TEST_RUN + +=item * TYPE_AFTER_TEST_RUN + +=item * TYPE_BEFORE_TEST_CASE + +=item * TYPE_AFTER_TEST_CASE + +=item * TYPE_BEFORE_TEST_STEP + +=item * TYPE_AFTER_TEST_STEP + +=back + +=cut + + +use constant { + TYPE_BEFORE_TEST_RUN => 'BEFORE_TEST_RUN', + TYPE_AFTER_TEST_RUN => 'AFTER_TEST_RUN', + TYPE_BEFORE_TEST_CASE => 'BEFORE_TEST_CASE', + TYPE_AFTER_TEST_CASE => 'AFTER_TEST_CASE', + TYPE_BEFORE_TEST_STEP => 'BEFORE_TEST_STEP', + TYPE_AFTER_TEST_STEP => 'AFTER_TEST_STEP', + }; + +has type => + (is => 'ro', + ); + + } package Cucumber::Messages::Location { diff --git a/php/src-generated/Hook.php b/php/src-generated/Hook.php index 5132d4b8..391b879d 100644 --- a/php/src-generated/Hook.php +++ b/php/src-generated/Hook.php @@ -29,6 +29,7 @@ public function __construct( public readonly ?string $name = null, public readonly SourceReference $sourceReference = new SourceReference(), public readonly ?string $tagExpression = null, + public readonly ?Hook\Type $type = null, ) { } @@ -43,12 +44,14 @@ public static function fromArray(array $arr): self self::ensureName($arr); self::ensureSourceReference($arr); self::ensureTagExpression($arr); + self::ensureType($arr); return new self( (string) $arr['id'], isset($arr['name']) ? (string) $arr['name'] : null, SourceReference::fromArray($arr['sourceReference']), isset($arr['tagExpression']) ? (string) $arr['tagExpression'] : null, + isset($arr['type']) ? Hook\Type::from((string) $arr['type']) : null, ); } @@ -97,4 +100,14 @@ private static function ensureTagExpression(array $arr): void throw new SchemaViolationException('Property \'tagExpression\' was array'); } } + + /** + * @psalm-assert array{type?: string|int|bool} $arr + */ + private static function ensureType(array $arr): void + { + if (array_key_exists('type', $arr) && is_array($arr['type'])) { + throw new SchemaViolationException('Property \'type\' was array'); + } + } } diff --git a/php/src-generated/Hook/Type.php b/php/src-generated/Hook/Type.php new file mode 100644 index 00000000..a3c24493 --- /dev/null +++ b/php/src-generated/Hook/Type.php @@ -0,0 +1,19 @@ + Date: Fri, 20 Sep 2024 20:28:23 +0100 Subject: [PATCH 14/18] update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b54e0db..bcc640bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] ### Added - BREAKING CHANGE: Add `id` property to `TestRunStarted`, optionally reference in `Attachment`, TestCase` and `TestRunFinished` ([#102](https://github.com/cucumber/messages/pull/102)) +- BREAKING CHANGE: Add `type` property to `Hook` ([#102](https://github.com/cucumber/messages/pull/102)) - Add new `TestRunHookStarted` and `TestRunHookFinished` messages ([#102](https://github.com/cucumber/messages/pull/102)) ### Fixed From c23af44feae2992038b75c311fdb32dd73e4584c Mon Sep 17 00:00:00 2001 From: David Goss Date: Sun, 22 Sep 2024 19:59:25 +0100 Subject: [PATCH 15/18] dont do testRunStartedId on TestCase, yet --- CHANGELOG.md | 2 +- .../messages/cucumber/messages/test_case.hpp | 1 - .../messages/cucumber/messages/test_case.cpp | 2 -- .../Cucumber.Messages/generated/TestCase.cs | 14 ++------------ go/messages.go | 7 +++---- .../io/cucumber/messages/types/TestCase.java | 19 +++---------------- javascript/src/messages.ts | 2 -- jsonschema/TestCase.json | 4 ---- messages.md | 1 - perl/lib/Cucumber/Messages.pm | 11 ----------- php/src-generated/TestCase.php | 17 ----------------- ruby/lib/cucumber/messages/test_case.rb | 12 ++---------- 12 files changed, 11 insertions(+), 81 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bcc640bf..3f1ca148 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] ### Added -- BREAKING CHANGE: Add `id` property to `TestRunStarted`, optionally reference in `Attachment`, TestCase` and `TestRunFinished` ([#102](https://github.com/cucumber/messages/pull/102)) +- BREAKING CHANGE: Add `id` property to `TestRunStarted`, optionally reference in `Attachment` and `TestRunFinished` ([#102](https://github.com/cucumber/messages/pull/102)) - BREAKING CHANGE: Add `type` property to `Hook` ([#102](https://github.com/cucumber/messages/pull/102)) - Add new `TestRunHookStarted` and `TestRunHookFinished` messages ([#102](https://github.com/cucumber/messages/pull/102)) diff --git a/cpp/include/messages/cucumber/messages/test_case.hpp b/cpp/include/messages/cucumber/messages/test_case.hpp index a5c726af..146c0e6d 100644 --- a/cpp/include/messages/cucumber/messages/test_case.hpp +++ b/cpp/include/messages/cucumber/messages/test_case.hpp @@ -27,7 +27,6 @@ struct test_case std::string id; std::string pickle_id; std::vector test_steps; - std::optional test_run_started_id; std::string to_string() const; diff --git a/cpp/src/lib/messages/cucumber/messages/test_case.cpp b/cpp/src/lib/messages/cucumber/messages/test_case.cpp index c2af5362..6a9070f3 100644 --- a/cpp/src/lib/messages/cucumber/messages/test_case.cpp +++ b/cpp/src/lib/messages/cucumber/messages/test_case.cpp @@ -13,7 +13,6 @@ test_case::to_string() const cucumber::messages::to_string(oss, "id=", id); cucumber::messages::to_string(oss, ", pickle_id=", pickle_id); cucumber::messages::to_string(oss, ", test_steps=", test_steps); - cucumber::messages::to_string(oss, ", test_run_started_id=", test_run_started_id); return oss.str(); } @@ -24,7 +23,6 @@ test_case::to_json(json& j) const cucumber::messages::to_json(j, camelize("id"), id); cucumber::messages::to_json(j, camelize("pickle_id"), pickle_id); cucumber::messages::to_json(j, camelize("test_steps"), test_steps); - cucumber::messages::to_json(j, camelize("test_run_started_id"), test_run_started_id); } std::string diff --git a/dotnet/Cucumber.Messages/generated/TestCase.cs b/dotnet/Cucumber.Messages/generated/TestCase.cs index 3b01a294..ff83e89a 100644 --- a/dotnet/Cucumber.Messages/generated/TestCase.cs +++ b/dotnet/Cucumber.Messages/generated/TestCase.cs @@ -26,17 +26,12 @@ public sealed class TestCase */ public string PickleId { get; private set; } public List TestSteps { get; private set; } - /** - * Identifier for the test run that this case belongs to - */ - public string TestRunStartedId { get; private set; } public TestCase( string id, string pickleId, - List testSteps, - string testRunStartedId + List testSteps ) { RequireNonNull(id, "Id", "TestCase.Id cannot be null"); @@ -45,7 +40,6 @@ string testRunStartedId this.PickleId = pickleId; RequireNonNull>(testSteps, "TestSteps", "TestCase.TestSteps cannot be null"); this.TestSteps = new List(testSteps); - this.TestRunStartedId = testRunStartedId; } public override bool Equals(Object o) @@ -56,8 +50,7 @@ public override bool Equals(Object o) return Id.Equals(that.Id) && PickleId.Equals(that.PickleId) && - TestSteps.Equals(that.TestSteps) && - Object.Equals(TestRunStartedId, that.TestRunStartedId); + TestSteps.Equals(that.TestSteps); } public override int GetHashCode() @@ -69,8 +62,6 @@ public override int GetHashCode() hash = hash * 31 + PickleId.GetHashCode(); if (TestSteps != null) hash = hash * 31 + TestSteps.GetHashCode(); - if (TestRunStartedId != null) - hash = hash * 31 + TestRunStartedId.GetHashCode(); return hash; } @@ -80,7 +71,6 @@ public override string ToString() "id=" + Id + ", pickleId=" + PickleId + ", testSteps=" + TestSteps + - ", testRunStartedId=" + TestRunStartedId + '}'; } diff --git a/go/messages.go b/go/messages.go index eaba8e4b..ba405d16 100644 --- a/go/messages.go +++ b/go/messages.go @@ -294,10 +294,9 @@ type StepDefinitionPattern struct { } type TestCase struct { - Id string `json:"id"` - PickleId string `json:"pickleId"` - TestSteps []*TestStep `json:"testSteps"` - TestRunStartedId string `json:"testRunStartedId,omitempty"` + Id string `json:"id"` + PickleId string `json:"pickleId"` + TestSteps []*TestStep `json:"testSteps"` } type Group struct { diff --git a/java/src/generated/java/io/cucumber/messages/types/TestCase.java b/java/src/generated/java/io/cucumber/messages/types/TestCase.java index 3cd74e3e..b7f99366 100644 --- a/java/src/generated/java/io/cucumber/messages/types/TestCase.java +++ b/java/src/generated/java/io/cucumber/messages/types/TestCase.java @@ -21,18 +21,15 @@ public final class TestCase { private final String id; private final String pickleId; private final java.util.List testSteps; - private final String testRunStartedId; public TestCase( String id, String pickleId, - java.util.List testSteps, - String testRunStartedId + java.util.List testSteps ) { this.id = requireNonNull(id, "TestCase.id cannot be null"); this.pickleId = requireNonNull(pickleId, "TestCase.pickleId cannot be null"); this.testSteps = unmodifiableList(new ArrayList<>(requireNonNull(testSteps, "TestCase.testSteps cannot be null"))); - this.testRunStartedId = testRunStartedId; } public String getId() { @@ -50,13 +47,6 @@ public java.util.List getTestSteps() { return testSteps; } - /** - * Identifier for the test run that this case belongs to - */ - public Optional getTestRunStartedId() { - return Optional.ofNullable(testRunStartedId); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -65,8 +55,7 @@ public boolean equals(Object o) { return id.equals(that.id) && pickleId.equals(that.pickleId) && - testSteps.equals(that.testSteps) && - Objects.equals(testRunStartedId, that.testRunStartedId); + testSteps.equals(that.testSteps); } @Override @@ -74,8 +63,7 @@ public int hashCode() { return Objects.hash( id, pickleId, - testSteps, - testRunStartedId + testSteps ); } @@ -85,7 +73,6 @@ public String toString() { "id=" + id + ", pickleId=" + pickleId + ", testSteps=" + testSteps + - ", testRunStartedId=" + testRunStartedId + '}'; } } diff --git a/javascript/src/messages.ts b/javascript/src/messages.ts index 86e8abe0..6235315f 100644 --- a/javascript/src/messages.ts +++ b/javascript/src/messages.ts @@ -547,8 +547,6 @@ export class TestCase { @Type(() => TestStep) testSteps: readonly TestStep[] = [] - - testRunStartedId?: string } export class Group { diff --git a/jsonschema/TestCase.json b/jsonschema/TestCase.json index bf4b13f2..ed4e8f9b 100644 --- a/jsonschema/TestCase.json +++ b/jsonschema/TestCase.json @@ -116,10 +116,6 @@ "$ref": "#/definitions/TestStep" }, "type": "array" - }, - "testRunStartedId": { - "description": "Identifier for the test run that this case belongs to", - "type": "string" } }, "type": "object" diff --git a/messages.md b/messages.md index a878324c..f76fd7c2 100644 --- a/messages.md +++ b/messages.md @@ -385,7 +385,6 @@ will only have one of its fields set, which indicates the payload of the message | `id` | string | yes | | | `pickleId` | string | yes | | | `testSteps` | [TestStep](#teststep)[] | yes | | -| `testRunStartedId` | string | no | | ## Group diff --git a/perl/lib/Cucumber/Messages.pm b/perl/lib/Cucumber/Messages.pm index 8996b695..550adcbf 100644 --- a/perl/lib/Cucumber/Messages.pm +++ b/perl/lib/Cucumber/Messages.pm @@ -3741,7 +3741,6 @@ my %types = ( id => 'string', pickle_id => 'string', test_steps => '[]Cucumber::Messages::TestStep', - test_run_started_id => 'string', ); # This is a work-around for the fact that Moo doesn't have introspection @@ -3788,16 +3787,6 @@ has test_steps => ); -=head4 test_run_started_id - -Identifier for the test run that this case belongs to -=cut - -has test_run_started_id => - (is => 'ro', - ); - - } package Cucumber::Messages::Group { diff --git a/php/src-generated/TestCase.php b/php/src-generated/TestCase.php index c74ac582..a9bd6f8d 100644 --- a/php/src-generated/TestCase.php +++ b/php/src-generated/TestCase.php @@ -35,11 +35,6 @@ public function __construct( */ public readonly string $pickleId = '', public readonly array $testSteps = [], - - /** - * Identifier for the test run that this case belongs to - */ - public readonly ?string $testRunStartedId = null, ) { } @@ -53,13 +48,11 @@ public static function fromArray(array $arr): self self::ensureId($arr); self::ensurePickleId($arr); self::ensureTestSteps($arr); - self::ensureTestRunStartedId($arr); return new self( (string) $arr['id'], (string) $arr['pickleId'], array_values(array_map(fn (array $member) => TestStep::fromArray($member), $arr['testSteps'])), - isset($arr['testRunStartedId']) ? (string) $arr['testRunStartedId'] : null, ); } @@ -101,14 +94,4 @@ private static function ensureTestSteps(array $arr): void throw new SchemaViolationException('Property \'testSteps\' was not array'); } } - - /** - * @psalm-assert array{testRunStartedId?: string|int|bool} $arr - */ - private static function ensureTestRunStartedId(array $arr): void - { - if (array_key_exists('testRunStartedId', $arr) && is_array($arr['testRunStartedId'])) { - throw new SchemaViolationException('Property \'testRunStartedId\' was array'); - } - } } diff --git a/ruby/lib/cucumber/messages/test_case.rb b/ruby/lib/cucumber/messages/test_case.rb index 5191d288..f90a994c 100644 --- a/ruby/lib/cucumber/messages/test_case.rb +++ b/ruby/lib/cucumber/messages/test_case.rb @@ -22,21 +22,14 @@ class TestCase < Message attr_reader :test_steps - ## - # Identifier for the test run that this case belongs to - ## - attr_reader :test_run_started_id - def initialize( id: '', pickle_id: '', - test_steps: [], - test_run_started_id: nil + test_steps: [] ) @id = id @pickle_id = pickle_id @test_steps = test_steps - @test_run_started_id = test_run_started_id super() end @@ -53,8 +46,7 @@ def self.from_h(hash) new( id: hash[:id], pickle_id: hash[:pickleId], - test_steps: hash[:testSteps]&.map { |item| TestStep.from_h(item) }, - test_run_started_id: hash[:testRunStartedId] + test_steps: hash[:testSteps]&.map { |item| TestStep.from_h(item) } ) end end From 1f3734147148eddb24510b98be7e9720952dbeac Mon Sep 17 00:00:00 2001 From: David Goss Date: Sun, 22 Sep 2024 20:04:37 +0100 Subject: [PATCH 16/18] rework CHANGELOG.md headings --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f1ca148..7367f5d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,9 +7,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] ### Added +- Add new `TestRunHookStarted` and `TestRunHookFinished` messages ([#102](https://github.com/cucumber/messages/pull/102)) + +### Changed - BREAKING CHANGE: Add `id` property to `TestRunStarted`, optionally reference in `Attachment` and `TestRunFinished` ([#102](https://github.com/cucumber/messages/pull/102)) - BREAKING CHANGE: Add `type` property to `Hook` ([#102](https://github.com/cucumber/messages/pull/102)) -- Add new `TestRunHookStarted` and `TestRunHookFinished` messages ([#102](https://github.com/cucumber/messages/pull/102)) ### Fixed - [Dotnet] Fixed code generation for types that accept List as parameters. Constructors were not properly handling null input. ([#249](https://github.com/cucumber/messages/pull/249) [clrudolphi]) From 57d3df73a495d51cb33daba07d07aafc05a5c93e Mon Sep 17 00:00:00 2001 From: David Goss Date: Tue, 15 Oct 2024 05:55:08 +0100 Subject: [PATCH 17/18] add testRunStartedId to TestCase --- .../messages/cucumber/messages/test_case.hpp | 1 + .../messages/cucumber/messages/test_case.cpp | 2 ++ .../Cucumber.Messages/generated/TestCase.cs | 14 ++++++++++++-- go/messages.go | 7 ++++--- .../io/cucumber/messages/types/TestCase.java | 19 ++++++++++++++++--- javascript/src/messages.ts | 2 ++ jsonschema/TestCase.json | 4 ++++ messages.md | 1 + perl/lib/Cucumber/Messages.pm | 11 +++++++++++ php/src-generated/TestCase.php | 17 +++++++++++++++++ ruby/lib/cucumber/messages/test_case.rb | 12 ++++++++++-- 11 files changed, 80 insertions(+), 10 deletions(-) diff --git a/cpp/include/messages/cucumber/messages/test_case.hpp b/cpp/include/messages/cucumber/messages/test_case.hpp index 146c0e6d..a5c726af 100644 --- a/cpp/include/messages/cucumber/messages/test_case.hpp +++ b/cpp/include/messages/cucumber/messages/test_case.hpp @@ -27,6 +27,7 @@ struct test_case std::string id; std::string pickle_id; std::vector test_steps; + std::optional test_run_started_id; std::string to_string() const; diff --git a/cpp/src/lib/messages/cucumber/messages/test_case.cpp b/cpp/src/lib/messages/cucumber/messages/test_case.cpp index 6a9070f3..c2af5362 100644 --- a/cpp/src/lib/messages/cucumber/messages/test_case.cpp +++ b/cpp/src/lib/messages/cucumber/messages/test_case.cpp @@ -13,6 +13,7 @@ test_case::to_string() const cucumber::messages::to_string(oss, "id=", id); cucumber::messages::to_string(oss, ", pickle_id=", pickle_id); cucumber::messages::to_string(oss, ", test_steps=", test_steps); + cucumber::messages::to_string(oss, ", test_run_started_id=", test_run_started_id); return oss.str(); } @@ -23,6 +24,7 @@ test_case::to_json(json& j) const cucumber::messages::to_json(j, camelize("id"), id); cucumber::messages::to_json(j, camelize("pickle_id"), pickle_id); cucumber::messages::to_json(j, camelize("test_steps"), test_steps); + cucumber::messages::to_json(j, camelize("test_run_started_id"), test_run_started_id); } std::string diff --git a/dotnet/Cucumber.Messages/generated/TestCase.cs b/dotnet/Cucumber.Messages/generated/TestCase.cs index ff83e89a..79667bbd 100644 --- a/dotnet/Cucumber.Messages/generated/TestCase.cs +++ b/dotnet/Cucumber.Messages/generated/TestCase.cs @@ -26,12 +26,17 @@ public sealed class TestCase */ public string PickleId { get; private set; } public List TestSteps { get; private set; } + /** + * Identifier for the test run that this test case belongs to + */ + public string TestRunStartedId { get; private set; } public TestCase( string id, string pickleId, - List testSteps + List testSteps, + string testRunStartedId ) { RequireNonNull(id, "Id", "TestCase.Id cannot be null"); @@ -40,6 +45,7 @@ List testSteps this.PickleId = pickleId; RequireNonNull>(testSteps, "TestSteps", "TestCase.TestSteps cannot be null"); this.TestSteps = new List(testSteps); + this.TestRunStartedId = testRunStartedId; } public override bool Equals(Object o) @@ -50,7 +56,8 @@ public override bool Equals(Object o) return Id.Equals(that.Id) && PickleId.Equals(that.PickleId) && - TestSteps.Equals(that.TestSteps); + TestSteps.Equals(that.TestSteps) && + Object.Equals(TestRunStartedId, that.TestRunStartedId); } public override int GetHashCode() @@ -62,6 +69,8 @@ public override int GetHashCode() hash = hash * 31 + PickleId.GetHashCode(); if (TestSteps != null) hash = hash * 31 + TestSteps.GetHashCode(); + if (TestRunStartedId != null) + hash = hash * 31 + TestRunStartedId.GetHashCode(); return hash; } @@ -71,6 +80,7 @@ public override string ToString() "id=" + Id + ", pickleId=" + PickleId + ", testSteps=" + TestSteps + + ", testRunStartedId=" + TestRunStartedId + '}'; } diff --git a/go/messages.go b/go/messages.go index ba405d16..eaba8e4b 100644 --- a/go/messages.go +++ b/go/messages.go @@ -294,9 +294,10 @@ type StepDefinitionPattern struct { } type TestCase struct { - Id string `json:"id"` - PickleId string `json:"pickleId"` - TestSteps []*TestStep `json:"testSteps"` + Id string `json:"id"` + PickleId string `json:"pickleId"` + TestSteps []*TestStep `json:"testSteps"` + TestRunStartedId string `json:"testRunStartedId,omitempty"` } type Group struct { diff --git a/java/src/generated/java/io/cucumber/messages/types/TestCase.java b/java/src/generated/java/io/cucumber/messages/types/TestCase.java index b7f99366..ee13d471 100644 --- a/java/src/generated/java/io/cucumber/messages/types/TestCase.java +++ b/java/src/generated/java/io/cucumber/messages/types/TestCase.java @@ -21,15 +21,18 @@ public final class TestCase { private final String id; private final String pickleId; private final java.util.List testSteps; + private final String testRunStartedId; public TestCase( String id, String pickleId, - java.util.List testSteps + java.util.List testSteps, + String testRunStartedId ) { this.id = requireNonNull(id, "TestCase.id cannot be null"); this.pickleId = requireNonNull(pickleId, "TestCase.pickleId cannot be null"); this.testSteps = unmodifiableList(new ArrayList<>(requireNonNull(testSteps, "TestCase.testSteps cannot be null"))); + this.testRunStartedId = testRunStartedId; } public String getId() { @@ -47,6 +50,13 @@ public java.util.List getTestSteps() { return testSteps; } + /** + * Identifier for the test run that this test case belongs to + */ + public Optional getTestRunStartedId() { + return Optional.ofNullable(testRunStartedId); + } + @Override public boolean equals(Object o) { if (this == o) return true; @@ -55,7 +65,8 @@ public boolean equals(Object o) { return id.equals(that.id) && pickleId.equals(that.pickleId) && - testSteps.equals(that.testSteps); + testSteps.equals(that.testSteps) && + Objects.equals(testRunStartedId, that.testRunStartedId); } @Override @@ -63,7 +74,8 @@ public int hashCode() { return Objects.hash( id, pickleId, - testSteps + testSteps, + testRunStartedId ); } @@ -73,6 +85,7 @@ public String toString() { "id=" + id + ", pickleId=" + pickleId + ", testSteps=" + testSteps + + ", testRunStartedId=" + testRunStartedId + '}'; } } diff --git a/javascript/src/messages.ts b/javascript/src/messages.ts index 6235315f..86e8abe0 100644 --- a/javascript/src/messages.ts +++ b/javascript/src/messages.ts @@ -547,6 +547,8 @@ export class TestCase { @Type(() => TestStep) testSteps: readonly TestStep[] = [] + + testRunStartedId?: string } export class Group { diff --git a/jsonschema/TestCase.json b/jsonschema/TestCase.json index ed4e8f9b..003d9e95 100644 --- a/jsonschema/TestCase.json +++ b/jsonschema/TestCase.json @@ -116,6 +116,10 @@ "$ref": "#/definitions/TestStep" }, "type": "array" + }, + "testRunStartedId": { + "description": "Identifier for the test run that this test case belongs to", + "type": "string" } }, "type": "object" diff --git a/messages.md b/messages.md index f76fd7c2..a878324c 100644 --- a/messages.md +++ b/messages.md @@ -385,6 +385,7 @@ will only have one of its fields set, which indicates the payload of the message | `id` | string | yes | | | `pickleId` | string | yes | | | `testSteps` | [TestStep](#teststep)[] | yes | | +| `testRunStartedId` | string | no | | ## Group diff --git a/perl/lib/Cucumber/Messages.pm b/perl/lib/Cucumber/Messages.pm index 550adcbf..9f76facf 100644 --- a/perl/lib/Cucumber/Messages.pm +++ b/perl/lib/Cucumber/Messages.pm @@ -3741,6 +3741,7 @@ my %types = ( id => 'string', pickle_id => 'string', test_steps => '[]Cucumber::Messages::TestStep', + test_run_started_id => 'string', ); # This is a work-around for the fact that Moo doesn't have introspection @@ -3787,6 +3788,16 @@ has test_steps => ); +=head4 test_run_started_id + +Identifier for the test run that this test case belongs to +=cut + +has test_run_started_id => + (is => 'ro', + ); + + } package Cucumber::Messages::Group { diff --git a/php/src-generated/TestCase.php b/php/src-generated/TestCase.php index a9bd6f8d..abf5aebb 100644 --- a/php/src-generated/TestCase.php +++ b/php/src-generated/TestCase.php @@ -35,6 +35,11 @@ public function __construct( */ public readonly string $pickleId = '', public readonly array $testSteps = [], + + /** + * Identifier for the test run that this test case belongs to + */ + public readonly ?string $testRunStartedId = null, ) { } @@ -48,11 +53,13 @@ public static function fromArray(array $arr): self self::ensureId($arr); self::ensurePickleId($arr); self::ensureTestSteps($arr); + self::ensureTestRunStartedId($arr); return new self( (string) $arr['id'], (string) $arr['pickleId'], array_values(array_map(fn (array $member) => TestStep::fromArray($member), $arr['testSteps'])), + isset($arr['testRunStartedId']) ? (string) $arr['testRunStartedId'] : null, ); } @@ -94,4 +101,14 @@ private static function ensureTestSteps(array $arr): void throw new SchemaViolationException('Property \'testSteps\' was not array'); } } + + /** + * @psalm-assert array{testRunStartedId?: string|int|bool} $arr + */ + private static function ensureTestRunStartedId(array $arr): void + { + if (array_key_exists('testRunStartedId', $arr) && is_array($arr['testRunStartedId'])) { + throw new SchemaViolationException('Property \'testRunStartedId\' was array'); + } + } } diff --git a/ruby/lib/cucumber/messages/test_case.rb b/ruby/lib/cucumber/messages/test_case.rb index f90a994c..da0eb60d 100644 --- a/ruby/lib/cucumber/messages/test_case.rb +++ b/ruby/lib/cucumber/messages/test_case.rb @@ -22,14 +22,21 @@ class TestCase < Message attr_reader :test_steps + ## + # Identifier for the test run that this test case belongs to + ## + attr_reader :test_run_started_id + def initialize( id: '', pickle_id: '', - test_steps: [] + test_steps: [], + test_run_started_id: nil ) @id = id @pickle_id = pickle_id @test_steps = test_steps + @test_run_started_id = test_run_started_id super() end @@ -46,7 +53,8 @@ def self.from_h(hash) new( id: hash[:id], pickle_id: hash[:pickleId], - test_steps: hash[:testSteps]&.map { |item| TestStep.from_h(item) } + test_steps: hash[:testSteps]&.map { |item| TestStep.from_h(item) }, + test_run_started_id: hash[:testRunStartedId] ) end end From d29111e1bbbba1ca9521dcd12821200f61c599ae Mon Sep 17 00:00:00 2001 From: David Goss Date: Sat, 26 Oct 2024 11:54:29 +0100 Subject: [PATCH 18/18] update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cca864de..cdc0c068 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Add new `TestRunHookStarted` and `TestRunHookFinished` messages ([#102](https://github.com/cucumber/messages/pull/102)) ### Changed -- BREAKING CHANGE: Add `id` property to `TestRunStarted`, optionally reference in `Attachment` and `TestRunFinished` ([#102](https://github.com/cucumber/messages/pull/102)) +- BREAKING CHANGE: Add `id` property to `TestRunStarted`, optionally reference in `TestCase`, `Attachment` and `TestRunFinished` ([#102](https://github.com/cucumber/messages/pull/102)) - BREAKING CHANGE: Add `type` property to `Hook` ([#102](https://github.com/cucumber/messages/pull/102)) ## [26.0.1] - 2024-09-22