Skip to content
Permalink
Browse files
feat(core): implemented the Stage
affects: @serenity-js/core, @serenity-js/cucumber, @integration/cucumber-5-runner,
@integration/cucumber, @integration/testing-tools,
@serenity-js-examples/cucumber-domain-level-testing, @serenity-js-examples/cucumber-reporting,
@documentation/website
  • Loading branch information
jan-molak committed Sep 16, 2018
1 parent c3bd443 commit ec5aa5d5d872e7bc0d24097f4df61191f2974580
Showing with 605 additions and 70 deletions.
  1. +1 −1 documentation/website/partials/footer.hbs
  2. +14 −6 examples/cucumber-domain-level-testing/features/step_definitions/domain-level.steps.ts
  3. +8 −0 examples/cucumber-domain-level-testing/features/support/Actors.ts
  4. +15 −10 examples/cucumber-domain-level-testing/features/support/configure_serenity.ts
  5. +1 −1 examples/cucumber-domain-level-testing/package.json
  6. +1 −1 examples/cucumber-reporting/package.json
  7. +1 −1 integration/cucumber-5-runner/package.json
  8. +2 −2 integration/cucumber/spec/ambiguous_steps.spec.ts
  9. +1 −1 integration/cucumber/spec/capabilities.spec.ts
  10. +1 −1 integration/cucumber/spec/data_table.spec.ts
  11. +2 −2 integration/cucumber/spec/descriptions.spec.ts
  12. +2 −2 integration/cucumber/spec/doc_string.spec.ts
  13. +2 −2 integration/cucumber/spec/failing_scenario.spec.ts
  14. +2 −2 integration/cucumber/spec/passing_scenario.spec.ts
  15. +9 −9 integration/cucumber/spec/pending_scenarios.spec.ts
  16. +2 −2 integration/cucumber/spec/scenario_outlines.spec.ts
  17. +4 −4 integration/cucumber/spec/tags.spec.ts
  18. +2 −2 integration/cucumber/spec/themes.spec.ts
  19. +2 −2 integration/cucumber/spec/timed_out_scenario.spec.ts
  20. +0 −1 integration/testing-tools/src/child-process-reporter/ChildProcessReporter.ts
  21. +1 −1 packages/core/spec/Recorder.ts
  22. +1 −1 packages/core/spec/screenplay/actor/Actor.spec.ts
  23. +158 −0 packages/core/spec/stage/Stage.spec.ts
  24. +1 −2 packages/core/spec/stage/StageManager.spec.ts
  25. +5 −1 packages/core/src/Serenity.ts
  26. +10 −0 packages/core/src/errors/ConfigurationError.ts
  27. +11 −0 packages/core/src/errors/LogicError.ts
  28. +24 −0 packages/core/src/errors/RuntimeError.ts
  29. +13 −0 packages/core/src/errors/TestCompromisedError.ts
  30. +2 −0 packages/core/src/errors/index.ts
  31. +1 −0 packages/core/src/screenplay/activities/ActivityDescriber.ts
  32. +1 −0 packages/core/src/screenplay/activities/OutcomeMatcher.ts
  33. +1 −0 packages/core/src/screenplay/activities/TrackedActivity.ts
  34. +4 −3 packages/core/src/screenplay/actor/Actor.ts
  35. +9 −0 packages/core/src/stage/Cast.ts
  36. +84 −0 packages/core/src/stage/Stage.ts
  37. +20 −3 packages/core/src/stage/StageCrewMember.ts
  38. +1 −0 packages/core/src/stage/StageManager.ts
  39. +148 −0 packages/core/src/stage/crew/console-reporter/ConsoleReporter.ts
  40. +1 −0 packages/core/src/stage/crew/console-reporter/index.ts
  41. +1 −0 packages/core/src/stage/crew/index.ts
  42. +1 −0 packages/core/src/stage/crew/serenity-bdd-reporter/reports/SceneReports.ts
  43. +1 −0 packages/core/src/stage/index.ts
  44. +1 −1 packages/cucumber/package.json
  45. +32 −0 packages/cucumber/src/WithStage.ts
  46. +1 −6 packages/cucumber/src/index.ts
@@ -26,7 +26,7 @@
<div class="container">
<div class="row">
<div class="col-lg-6 mx-auto ftr-bt ftr-oneline ">
&copy; 2016 - 2018 <a href="https://janmolak.com" target="_blank">Jan Molak</a>, smartcode ltd.
Made with love in London, UK &copy; 2016 - 2018 <a href="https://janmolak.com" target="_blank">Jan Molak</a>, smartcode ltd.
</div>
</div>
</div>
@@ -1,13 +1,21 @@
import { WithStage } from '@serenity-js/cucumber';
import { Then, When } from 'cucumber';

When(/(.*?) enters (\d+)/, function(actorName: any, operandValue: string) {
return 'pending';
When(/(.*?) enters (\d+)/, function(this: WithStage, actorName: any, operandValue: string) {
// todo: an empty attemptsTo should result in a pending step
return this.stage.actor(actorName).attemptsTo(

);
});

When(/(?:he|she|they) uses? the (.*) operator/, function(operatorName: string) {
return 'pending';
When(/(?:he|she|they) uses? the (.*) operator/, function(this: WithStage, operatorName: string) {
return this.stage.currentActor().attemptsTo(

);
});

Then(/(?:he|she|they) should get a result of (\d+)/, function(expectedResult: string) {
return 'pending';
Then(/(?:he|she|they) should get a result of (\d+)/, function(this: WithStage, expectedResult: string) {
return this.stage.currentActor().attemptsTo(

);
});
@@ -0,0 +1,8 @@
import { Actor } from '@serenity-js/core';
import { Cast } from '@serenity-js/core/lib/stage';

export class Actors implements Cast {
actor(name: string) {
return Actor.named(name);
}
}
@@ -1,19 +1,24 @@
import { serenity } from '@serenity-js/core';
import { FileSystem, Path } from '@serenity-js/core/lib/io';
import { ArtifactArchiver, SerenityBDDReporter } from '@serenity-js/core/lib/stage';
import { ArtifactArchiver, ConsoleReporter, DebugReporter, SerenityBDDReporter, Stage } from '@serenity-js/core/lib/stage';

import { setDefaultTimeout } from 'cucumber';
import { setDefaultTimeout, setWorldConstructor } from 'cucumber';
import { Actors } from './Actors';

setDefaultTimeout(5000);

// todo: should probably come with @serenity-js/cucumber
interface WithStage {
stage: Stage;
}

setWorldConstructor(function(this: WithStage, { parameters }) {
this.stage = serenity.callToStageFor(new Actors());
});

// todo: implement serenity.configure(...)
const crewMembers = [
serenity.stageManager.register(
new ArtifactArchiver(new FileSystem(new Path('./target/site/serenity'))),
new SerenityBDDReporter(),
// new DebugReporter(),
];

crewMembers.forEach(crewMember => {
crewMember.assignTo(serenity.stageManager);
serenity.stageManager.register(crewMember);
});
new ConsoleReporter(process.stdout),
);
@@ -40,7 +40,7 @@
"@serenity-js/cucumber": "*",
"@serenity-js-examples/calculator-app": "*",
"@types/cucumber": "4.0.4",
"cucumber": "5.0.0",
"cucumber": "5.0.1",
"npm-failsafe": "0.4.1",
"serenity-cli": "0.11.0",
"ts-node": "7.0.1"
@@ -39,7 +39,7 @@
"@serenity-js/core": "*",
"@serenity-js/cucumber": "*",
"@types/cucumber": "4.0.4",
"cucumber": "5.0.0",
"cucumber": "5.0.1",
"npm-failsafe": "0.4.1",
"serenity-cli": "0.11.0",
"ts-node": "7.0.1"
@@ -36,7 +36,7 @@
"@integration/testing-tools": "*",
"@serenity-js/core": "*",
"@serenity-js/cucumber": "*",
"cucumber": "5.0.0"
"cucumber": "5.0.1"
},
"devDependencies": {
"@types/cucumber": "4.0.4"
@@ -20,7 +20,7 @@ describe('@serenity-js/cucumber', function() {
given([
...cucumberVersions(1, 2)
.thatRequires(
'node_modules/@serenity-js/cucumber/lib/register.js',
'node_modules/@serenity-js/cucumber/register.js',
'lib/support/configure_serenity.js',
)
.withStepDefsIn('ambiguous')
@@ -30,7 +30,7 @@ describe('@serenity-js/cucumber', function() {
.thatRequires('lib/support/configure_serenity.js')
.withStepDefsIn('ambiguous')
.withArgs(
'--format', 'node_modules/@serenity-js/cucumber',
'--format', 'node_modules/@serenity-js/cucumber/register.js',
)
.toRun('features/passing_scenario.feature'),
]).
@@ -23,7 +23,7 @@ describe('@serenity-js/cucumber', function() {
.thatRequires('lib/support/configure_serenity.js')
.withStepDefsIn('synchronous', 'promise', 'callback')
.withArgs(
'--format', 'node_modules/@serenity-js/cucumber',
'--format', 'node_modules/@serenity-js/cucumber/register.js',
)
.toRun('features/example_capability/example.feature'),
]).
@@ -23,7 +23,7 @@ describe('@serenity-js/cucumber', function() {
.thatRequires('lib/support/configure_serenity.js')
.withStepDefsIn('synchronous', 'promise', 'callback')
.withArgs(
'--format', 'node_modules/@serenity-js/cucumber',
'--format', 'node_modules/@serenity-js/cucumber/register.js',
)
.toRun('features/data_table.feature'),
]).
@@ -13,7 +13,7 @@ describe('@serenity-js/cucumber', function() {
given([
...cucumberVersions(1, 2)
.thatRequires(
'node_modules/@serenity-js/cucumber/lib/register.js',
'node_modules/@serenity-js/cucumber/register.js',
'lib/support/configure_serenity.js',
)
.withStepDefsIn('promise', 'callback', 'synchronous')
@@ -23,7 +23,7 @@ describe('@serenity-js/cucumber', function() {
.thatRequires('lib/support/configure_serenity.js')
.withStepDefsIn('synchronous', 'promise', 'callback')
.withArgs(
'--format', 'node_modules/@serenity-js/cucumber',
'--format', 'node_modules/@serenity-js/cucumber/register.js',
)
.toRun('features/descriptions.feature'),
]).
@@ -13,7 +13,7 @@ describe('@serenity-js/cucumber', function() {
given([
...cucumberVersions(1, 2)
.thatRequires(
'node_modules/@serenity-js/cucumber/lib/register.js',
'node_modules/@serenity-js/cucumber/register.js',
'lib/support/configure_serenity.js',
)
.withStepDefsIn('promise', 'callback', 'synchronous')
@@ -23,7 +23,7 @@ describe('@serenity-js/cucumber', function() {
.thatRequires('lib/support/configure_serenity.js')
.withStepDefsIn('synchronous', 'promise', 'callback')
.withArgs(
'--format', 'node_modules/@serenity-js/cucumber',
'--format', 'node_modules/@serenity-js/cucumber/register.js',
)
.toRun('features/doc_strings.feature'),
]).
@@ -20,7 +20,7 @@ describe('@serenity-js/cucumber', function() {
given([
...cucumberVersions(1, 2)
.thatRequires(
'node_modules/@serenity-js/cucumber/lib/register.js',
'node_modules/@serenity-js/cucumber/register.js',
'lib/support/configure_serenity.js',
)
.withStepDefsIn('promise', 'callback', 'synchronous')
@@ -30,7 +30,7 @@ describe('@serenity-js/cucumber', function() {
.thatRequires('lib/support/configure_serenity.js')
.withStepDefsIn('synchronous', 'promise', 'callback')
.withArgs(
'--format', 'node_modules/@serenity-js/cucumber',
'--format', 'node_modules/@serenity-js/cucumber/register.js',
)
.toRun('features/failing_scenario.feature'),
]).
@@ -20,7 +20,7 @@ describe('@serenity-js/cucumber', function() {
given([
...cucumberVersions(1, 2)
.thatRequires(
'node_modules/@serenity-js/cucumber/lib/register.js',
'node_modules/@serenity-js/cucumber/register.js',
'lib/support/configure_serenity.js',
)
.withStepDefsIn('synchronous', 'promise', 'callback')
@@ -30,7 +30,7 @@ describe('@serenity-js/cucumber', function() {
.thatRequires('lib/support/configure_serenity.js')
.withStepDefsIn('synchronous', 'promise', 'callback')
.withArgs(
'--format', 'node_modules/@serenity-js/cucumber',
'--format', 'node_modules/@serenity-js/cucumber/register.js',
)
.toRun('features/passing_scenario.feature'),
]).
@@ -21,7 +21,7 @@ describe('@serenity-js/cucumber', function() {
given([
...cucumberVersions(1)
.thatRequires(
'node_modules/@serenity-js/cucumber/lib/register.js',
'node_modules/@serenity-js/cucumber/register.js',
'lib/support/configure_serenity.js',
)
.withStepDefsIn('promise', 'callback', 'synchronous')
@@ -30,7 +30,7 @@ describe('@serenity-js/cucumber', function() {

...cucumberVersions(2)
.thatRequires(
'node_modules/@serenity-js/cucumber/lib/register.js',
'node_modules/@serenity-js/cucumber/register.js',
'lib/support/configure_serenity.js',
)
.withStepDefsIn('promise', 'callback', 'synchronous')
@@ -41,7 +41,7 @@ describe('@serenity-js/cucumber', function() {
.thatRequires('lib/support/configure_serenity.js')
.withStepDefsIn('synchronous', 'promise', 'callback')
.withArgs(
'--format', 'node_modules/@serenity-js/cucumber',
'--format', 'node_modules/@serenity-js/cucumber/register.js',
'--name', 'A scenario with steps marked as pending',
'--no-strict',
)
@@ -65,7 +65,7 @@ describe('@serenity-js/cucumber', function() {
given([
...cucumberVersions(1)
.thatRequires(
'node_modules/@serenity-js/cucumber/lib/register.js',
'node_modules/@serenity-js/cucumber/register.js',
'lib/support/configure_serenity.js',
)
.withStepDefsIn('promise', 'callback', 'synchronous')
@@ -74,7 +74,7 @@ describe('@serenity-js/cucumber', function() {

...cucumberVersions(2)
.thatRequires(
'node_modules/@serenity-js/cucumber/lib/register.js',
'node_modules/@serenity-js/cucumber/register.js',
'lib/support/configure_serenity.js',
)
.withStepDefsIn('promise', 'callback', 'synchronous')
@@ -85,7 +85,7 @@ describe('@serenity-js/cucumber', function() {
.thatRequires('lib/support/configure_serenity.js')
.withStepDefsIn('synchronous', 'promise', 'callback')
.withArgs(
'--format', 'node_modules/@serenity-js/cucumber',
'--format', 'node_modules/@serenity-js/cucumber/register.js',
// '--no-strict', // cucumber 3 ignores the --no-strict mode
'--name', 'A scenario with steps that have not been implemented yet',
)
@@ -109,7 +109,7 @@ describe('@serenity-js/cucumber', function() {
given([
...cucumberVersions(1)
.thatRequires(
'node_modules/@serenity-js/cucumber/lib/register.js',
'node_modules/@serenity-js/cucumber/register.js',
'lib/support/configure_serenity.js',
'lib/support/wip_hook.js',
)
@@ -119,7 +119,7 @@ describe('@serenity-js/cucumber', function() {

...cucumberVersions(2)
.thatRequires(
'node_modules/@serenity-js/cucumber/lib/register.js',
'node_modules/@serenity-js/cucumber/register.js',
'lib/support/configure_serenity.js',
'lib/support/wip_hook.js',
)
@@ -154,7 +154,7 @@ describe('@serenity-js/cucumber', function() {
)
.withStepDefsIn('synchronous', 'promise', 'callback')
.withArgs(
'--format', 'node_modules/@serenity-js/cucumber',
'--format', 'node_modules/@serenity-js/cucumber/register.js',
'--name', 'A scenario which tag marks it as pending',
// '--no-strict',
)
@@ -18,7 +18,7 @@ describe('@serenity-js/cucumber', function() {
given([
...cucumberVersions(1, 2)
.thatRequires(
'node_modules/@serenity-js/cucumber/lib/register.js',
'node_modules/@serenity-js/cucumber/register.js',
'lib/support/configure_serenity.js',
)
.withStepDefsIn('promise', 'callback', 'synchronous')
@@ -28,7 +28,7 @@ describe('@serenity-js/cucumber', function() {
.thatRequires('lib/support/configure_serenity.js')
.withStepDefsIn('synchronous', 'promise', 'callback')
.withArgs(
'--format', 'node_modules/@serenity-js/cucumber',
'--format', 'node_modules/@serenity-js/cucumber/register.js',
)
.toRun('features/scenario_outlines.feature'),
]).
@@ -13,7 +13,7 @@ describe('@serenity-js/cucumber', function() {
given([
...cucumberVersions(1, 2)
.thatRequires(
'node_modules/@serenity-js/cucumber/lib/register.js',
'node_modules/@serenity-js/cucumber/register.js',
'lib/support/configure_serenity.js',
)
.withStepDefsIn('promise', 'callback', 'synchronous')
@@ -24,7 +24,7 @@ describe('@serenity-js/cucumber', function() {
.thatRequires('lib/support/configure_serenity.js')
.withStepDefsIn('synchronous', 'promise', 'callback')
.withArgs(
'--format', 'node_modules/@serenity-js/cucumber',
'--format', 'node_modules/@serenity-js/cucumber/register.js',
)
.toRun('features/tags.feature'),
]).
@@ -44,7 +44,7 @@ describe('@serenity-js/cucumber', function() {
given([
...cucumberVersions(1, 2)
.thatRequires(
'node_modules/@serenity-js/cucumber/lib/register.js',
'node_modules/@serenity-js/cucumber/register.js',
'lib/support/configure_serenity.js',
)
.withStepDefsIn('promise', 'callback', 'synchronous')
@@ -55,7 +55,7 @@ describe('@serenity-js/cucumber', function() {
.thatRequires('lib/support/configure_serenity.js')
.withStepDefsIn('synchronous', 'promise', 'callback')
.withArgs(
'--format', 'node_modules/@serenity-js/cucumber',
'--format', 'node_modules/@serenity-js/cucumber/register.js',
'--name', 'More tagged scenarios',
)
.toRun('features/tags.feature'),
@@ -13,7 +13,7 @@ describe('@serenity-js/cucumber', function() {
given([
...cucumberVersions(1, 2)
.thatRequires(
'node_modules/@serenity-js/cucumber/lib/register.js',
'node_modules/@serenity-js/cucumber/register.js',
'lib/support/configure_serenity.js',
)
.withStepDefsIn('promise', 'callback', 'synchronous')
@@ -23,7 +23,7 @@ describe('@serenity-js/cucumber', function() {
.thatRequires('lib/support/configure_serenity.js')
.withStepDefsIn('synchronous', 'promise', 'callback')
.withArgs(
'--format', 'node_modules/@serenity-js/cucumber',
'--format', 'node_modules/@serenity-js/cucumber/register.js',
)
.toRun('features/example_theme/example_capability/example.feature'),
]).
@@ -20,7 +20,7 @@ describe('@serenity-js/cucumber', function() {
given([
...cucumberVersions(1, 2)
.thatRequires(
'node_modules/@serenity-js/cucumber/lib/register.js',
'node_modules/@serenity-js/cucumber/register.js',
'lib/support/configure_serenity.js',
)
.withStepDefsIn('promise', 'callback')
@@ -30,7 +30,7 @@ describe('@serenity-js/cucumber', function() {
.thatRequires('lib/support/configure_serenity.js')
.withStepDefsIn('promise', 'callback')
.withArgs(
'--format', 'node_modules/@serenity-js/cucumber',
'--format', 'node_modules/@serenity-js/cucumber/register.js',
)
.toRun('features/timed_out_scenario.feature'),
]).
@@ -8,7 +8,6 @@ export class ChildProcessReporter implements StageCrewMember {

assignTo(stageManager: StageManager) {
this.stageManager = stageManager;
this.stageManager.register(this);
}

notifyOf(event: DomainEvent): void {

0 comments on commit ec5aa5d

Please sign in to comment.