Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
### Added
- Add `Attachment.testRunHookStartedId` for traceability of attachments to test run hooks ([#301](https://github.com/cucumber/messages/pull/301))

### Fixed
- [python] Add a LICENSE file for Python ([#278](https://github.com/cucumber/messages/pull/278))
Expand Down
1 change: 1 addition & 0 deletions cpp/include/messages/cucumber/messages/attachment.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ struct attachment
std::optional<std::string> test_step_id;
std::optional<std::string> url;
std::optional<std::string> test_run_started_id;
std::optional<std::string> test_run_hook_started_id;

std::string to_string() const;

Expand Down
2 changes: 2 additions & 0 deletions cpp/src/lib/messages/cucumber/messages/attachment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ attachment::to_string() const
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);
cucumber::messages::to_string(oss, ", test_run_hook_started_id=", test_run_hook_started_id);

return oss.str();
}
Expand All @@ -35,6 +36,7 @@ attachment::to_json(json& j) const
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);
cucumber::messages::to_json(j, camelize("test_run_hook_started_id"), test_run_hook_started_id);
}

std::string
Expand Down
23 changes: 21 additions & 2 deletions dotnet/Cucumber.Messages/generated/Attachment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,13 @@ public sealed class Attachment
*/
public string MediaType { get; private set; }
public Source Source { get; private set; }
/**
* The identifier of the test case attempt if the attachment was created during the execution of a test step
*/
public string TestCaseStartedId { get; private set; }
/**
* The identifier of the test step if the attachment was created during the execution of a test step
*/
public string TestStepId { get; private set; }
/**
* A URL where the attachment can be retrieved. This field should not be set by Cucumber.
Expand All @@ -73,7 +79,14 @@ public sealed class Attachment
* separately from reports.
*/
public string Url { get; private set; }
/**
* Not used; implementers should instead populate `testRunHookStartedId` if an attachment was created during the execution of a test run hook
*/
public string TestRunStartedId { get; private set; }
/**
* The identifier of the test run hook execution if the attachment was created during the execution of a test run hook
*/
public string TestRunHookStartedId { get; private set; }


public Attachment(
Expand All @@ -85,7 +98,8 @@ public Attachment(
string testCaseStartedId,
string testStepId,
string url,
string testRunStartedId
string testRunStartedId,
string testRunHookStartedId
)
{
RequireNonNull<string>(body, "Body", "Attachment.Body cannot be null");
Expand All @@ -100,6 +114,7 @@ string testRunStartedId
this.TestStepId = testStepId;
this.Url = url;
this.TestRunStartedId = testRunStartedId;
this.TestRunHookStartedId = testRunHookStartedId;
}

public override bool Equals(Object o)
Expand All @@ -116,7 +131,8 @@ public override bool Equals(Object o)
Object.Equals(TestCaseStartedId, that.TestCaseStartedId) &&
Object.Equals(TestStepId, that.TestStepId) &&
Object.Equals(Url, that.Url) &&
Object.Equals(TestRunStartedId, that.TestRunStartedId);
Object.Equals(TestRunStartedId, that.TestRunStartedId) &&
Object.Equals(TestRunHookStartedId, that.TestRunHookStartedId);
}

public override int GetHashCode()
Expand All @@ -139,6 +155,8 @@ public override int GetHashCode()
hash = hash * 31 + Url.GetHashCode();
if (TestRunStartedId != null)
hash = hash * 31 + TestRunStartedId.GetHashCode();
if (TestRunHookStartedId != null)
hash = hash * 31 + TestRunHookStartedId.GetHashCode();
return hash;
}

Expand All @@ -154,6 +172,7 @@ public override string ToString()
", testStepId=" + TestStepId +
", url=" + Url +
", testRunStartedId=" + TestRunStartedId +
", testRunHookStartedId=" + TestRunHookStartedId +
'}';
}

Expand Down
19 changes: 10 additions & 9 deletions go/messages.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package messages

type Attachment struct {
Body string `json:"body"`
ContentEncoding AttachmentContentEncoding `json:"contentEncoding"`
FileName string `json:"fileName,omitempty"`
MediaType string `json:"mediaType"`
Source *Source `json:"source,omitempty"`
TestCaseStartedId string `json:"testCaseStartedId,omitempty"`
TestStepId string `json:"testStepId,omitempty"`
Url string `json:"url,omitempty"`
TestRunStartedId string `json:"testRunStartedId,omitempty"`
Body string `json:"body"`
ContentEncoding AttachmentContentEncoding `json:"contentEncoding"`
FileName string `json:"fileName,omitempty"`
MediaType string `json:"mediaType"`
Source *Source `json:"source,omitempty"`
TestCaseStartedId string `json:"testCaseStartedId,omitempty"`
TestStepId string `json:"testStepId,omitempty"`
Url string `json:"url,omitempty"`
TestRunStartedId string `json:"testRunStartedId,omitempty"`
TestRunHookStartedId string `json:"testRunHookStartedId,omitempty"`
}

type Duration struct {
Expand Down
28 changes: 25 additions & 3 deletions java/src/generated/java/io/cucumber/messages/types/Attachment.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public final class Attachment {
private final String testStepId;
private final String url;
private final String testRunStartedId;
private final String testRunHookStartedId;

public Attachment(
String body,
Expand All @@ -45,7 +46,8 @@ public Attachment(
String testCaseStartedId,
String testStepId,
String url,
String testRunStartedId
String testRunStartedId,
String testRunHookStartedId
) {
this.body = requireNonNull(body, "Attachment.body cannot be null");
this.contentEncoding = requireNonNull(contentEncoding, "Attachment.contentEncoding cannot be null");
Expand All @@ -56,6 +58,7 @@ public Attachment(
this.testStepId = testStepId;
this.url = url;
this.testRunStartedId = testRunStartedId;
this.testRunHookStartedId = testRunHookStartedId;
}

/**
Expand Down Expand Up @@ -102,10 +105,16 @@ public Optional<Source> getSource() {
return Optional.ofNullable(source);
}

/**
* The identifier of the test case attempt if the attachment was created during the execution of a test step
*/
public Optional<String> getTestCaseStartedId() {
return Optional.ofNullable(testCaseStartedId);
}

/**
* The identifier of the test step if the attachment was created during the execution of a test step
*/
public Optional<String> getTestStepId() {
return Optional.ofNullable(testStepId);
}
Expand All @@ -127,10 +136,20 @@ public Optional<String> getUrl() {
return Optional.ofNullable(url);
}

/**
* Not used; implementers should instead populate `testRunHookStartedId` if an attachment was created during the execution of a test run hook
*/
public Optional<String> getTestRunStartedId() {
return Optional.ofNullable(testRunStartedId);
}

/**
* The identifier of the test run hook execution if the attachment was created during the execution of a test run hook
*/
public Optional<String> getTestRunHookStartedId() {
return Optional.ofNullable(testRunHookStartedId);
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand All @@ -145,7 +164,8 @@ public boolean equals(Object o) {
Objects.equals(testCaseStartedId, that.testCaseStartedId) &&
Objects.equals(testStepId, that.testStepId) &&
Objects.equals(url, that.url) &&
Objects.equals(testRunStartedId, that.testRunStartedId);
Objects.equals(testRunStartedId, that.testRunStartedId) &&
Objects.equals(testRunHookStartedId, that.testRunHookStartedId);
}

@Override
Expand All @@ -159,7 +179,8 @@ public int hashCode() {
testCaseStartedId,
testStepId,
url,
testRunStartedId
testRunStartedId,
testRunHookStartedId
);
}

Expand All @@ -175,6 +196,7 @@ public String toString() {
", testStepId=" + testStepId +
", url=" + url +
", testRunStartedId=" + testRunStartedId +
", testRunHookStartedId=" + testRunHookStartedId +
'}';
}
}
2 changes: 1 addition & 1 deletion java/src/test/java/io/cucumber/messages/MessagesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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, null);
new Attachment(null, null, null, null, null, null, null, null, null, null);
}, "Attachment.body cannot be null");
}

Expand Down
2 changes: 2 additions & 0 deletions javascript/src/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export class Attachment {
url?: string

testRunStartedId?: string

testRunHookStartedId?: string
}

export class Duration {
Expand Down
8 changes: 8 additions & 0 deletions jsonschema/Attachment.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,24 @@
"$ref": "./Source.json"
},
"testCaseStartedId": {
"description": "The identifier of the test case attempt if the attachment was created during the execution of a test step",
"type": "string"
},
"testStepId": {
"description": "The identifier of the test step if the attachment was created during the execution of a test step",
"type": "string"
},
"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": {
"description": "Not used; implementers should instead populate `testRunHookStartedId` if an attachment was created during the execution of a test run hook",
"type": "string",
"deprecated": true
},
"testRunHookStartedId": {
"description": "The identifier of the test run hook execution if the attachment was created during the execution of a test run hook",
"type": "string"
}
},
Expand Down
1 change: 1 addition & 0 deletions messages.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ will only have one of its fields set, which indicates the payload of the message
| `testStepId` | string | no | |
| `url` | string | no | |
| `testRunStartedId` | string | no | |
| `testRunHookStartedId` | string | no | |

## Duration

Expand Down
17 changes: 14 additions & 3 deletions perl/lib/Cucumber/Messages.pm
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ my %types = (
test_step_id => 'string',
url => 'string',
test_run_started_id => 'string',
test_run_hook_started_id => 'string',
);

# This is a work-around for the fact that Moo doesn't have introspection
Expand Down Expand Up @@ -188,7 +189,7 @@ has source =>

=head4 test_case_started_id


The identifier of the test case attempt if the attachment was created during the execution of a test step
=cut

has test_case_started_id =>
Expand All @@ -198,7 +199,7 @@ has test_case_started_id =>

=head4 test_step_id


The identifier of the test step if the attachment was created during the execution of a test step
=cut

has test_step_id =>
Expand Down Expand Up @@ -229,14 +230,24 @@ has url =>

=head4 test_run_started_id


Not used; implementers should instead populate `testRunHookStartedId` if an attachment was created during the execution of a test run hook
=cut

has test_run_started_id =>
(is => 'ro',
);


=head4 test_run_hook_started_id

The identifier of the test run hook execution if the attachment was created during the execution of a test run hook
=cut

has test_run_hook_started_id =>
(is => 'ro',
);


}

package Cucumber::Messages::Duration {
Expand Down
29 changes: 29 additions & 0 deletions php/src-generated/Attachment.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,15 @@ public function __construct(
*/
public readonly string $mediaType = '',
public readonly ?Source $source = null,

/**
* The identifier of the test case attempt if the attachment was created during the execution of a test step
*/
public readonly ?string $testCaseStartedId = null,

/**
* The identifier of the test step if the attachment was created during the execution of a test step
*/
public readonly ?string $testStepId = null,

/**
Expand All @@ -85,7 +93,16 @@ public function __construct(
* separately from reports.
*/
public readonly ?string $url = null,

/**
* Not used; implementers should instead populate `testRunHookStartedId` if an attachment was created during the execution of a test run hook
*/
public readonly ?string $testRunStartedId = null,

/**
* The identifier of the test run hook execution if the attachment was created during the execution of a test run hook
*/
public readonly ?string $testRunHookStartedId = null,
) {
}

Expand All @@ -105,6 +122,7 @@ public static function fromArray(array $arr): self
self::ensureTestStepId($arr);
self::ensureUrl($arr);
self::ensureTestRunStartedId($arr);
self::ensureTestRunHookStartedId($arr);

return new self(
(string) $arr['body'],
Expand All @@ -116,6 +134,7 @@ public static function fromArray(array $arr): self
isset($arr['testStepId']) ? (string) $arr['testStepId'] : null,
isset($arr['url']) ? (string) $arr['url'] : null,
isset($arr['testRunStartedId']) ? (string) $arr['testRunStartedId'] : null,
isset($arr['testRunHookStartedId']) ? (string) $arr['testRunHookStartedId'] : null,
);
}

Expand Down Expand Up @@ -217,4 +236,14 @@ private static function ensureTestRunStartedId(array $arr): void
throw new SchemaViolationException('Property \'testRunStartedId\' was array');
}
}

/**
* @psalm-assert array{testRunHookStartedId?: string|int|bool} $arr
*/
private static function ensureTestRunHookStartedId(array $arr): void
{
if (array_key_exists('testRunHookStartedId', $arr) && is_array($arr['testRunHookStartedId'])) {
throw new SchemaViolationException('Property \'testRunHookStartedId\' was array');
}
}
}
Loading
Loading