Skip to content

Commit

Permalink
Add example for the AsciiDoc reported after TNG#1299 is merged
Browse files Browse the repository at this point in the history
This should provide the example as requested in TNG#54.
  • Loading branch information
johthor committed May 24, 2023
1 parent f347c1a commit 79e63a8
Show file tree
Hide file tree
Showing 37 changed files with 2,334 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.gradle
64 changes: 64 additions & 0 deletions current/allScenarios.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
== All Scenarios

include::features/com.tngtech.jgiven.examples.description.AsAnnotationExampleTest.asciidoc[]

include::features/com.tngtech.jgiven.examples.attachments.AttachmentsExample.asciidoc[]

include::features/com.tngtech.jgiven.examples.userguide.CalculatorTest.asciidoc[]

include::features/com.tngtech.jgiven.examples.subclassing.CommonStagesTest.asciidoc[]

include::features/com.tngtech.jgiven.examples.description.CurrentStepExampleTest.asciidoc[]

include::features/com.tngtech.jgiven.examples.datatable.DataTableExamples.asciidoc[]

include::features/com.tngtech.jgiven.examples.tags.DynamicTags.asciidoc[]

include::features/com.tngtech.jgiven.examples.description.ExtendedDescriptionsTest.asciidoc[]

include::features/com.tngtech.jgiven.examples.userguide.ExtendedVocabularyTest.asciidoc[]

include::features/com.tngtech.jgiven.examples.pancakes.test.ExtendedVocabularyPanCakeTest.asciidoc[]

include::features/com.tngtech.jgiven.examples.FailingScenarioTest.asciidoc[]

include::features/com.tngtech.jgiven.examples.coffeemachine.JUnitParamsServeCoffeeTest.asciidoc[]

include::features/com.tngtech.jgiven.examples.links.LinkExampleOneTest.asciidoc[]

include::features/com.tngtech.jgiven.examples.links.LinkExampleTwoTest.asciidoc[]

include::features/com.tngtech.jgiven.examples.userguide.MyDynamicallyAddedTest.asciidoc[]

include::features/com.tngtech.jgiven.examples.userguide.MyInjectedJGivenTest.asciidoc[]

include::features/com.tngtech.jgiven.examples.userguide.MyShinyJGivenTest.asciidoc[]

include::features/com.tngtech.jgiven.examples.nested.NestedStepsTest.asciidoc[]

include::features/com.tngtech.jgiven.examples.parameters.ParameterFormattingTest.asciidoc[]

include::features/com.tngtech.jgiven.examples.pancakes.test.ParameterizedPanCakeScenarioTest.asciidoc[]

include::features/com.tngtech.jgiven.examples.parameters.ParametrizedScenariosTest.asciidoc[]

include::features/com.tngtech.jgiven.examples.pending.PendingExampleTest.asciidoc[]

include::features/com.tngtech.jgiven.examples.userguide.RocketTest.asciidoc[]

include::features/com.tngtech.jgiven.examples.rules.RulesExampleTest.asciidoc[]

include::features/com.tngtech.jgiven.examples.sections.SectionTest.asciidoc[]

include::features/com.tngtech.jgiven.examples.coffeemachine.ServeCoffeeTest.asciidoc[]

include::features/com.tngtech.jgiven.examples.simpletestcase.SimpleScenarioTestExampleTest.asciidoc[]

include::features/com.tngtech.jgiven.examples.pancakes.test.SpringPanCakeScenarioTest.asciidoc[]

include::features/com.tngtech.jgiven.examples.tags.StepTags.asciidoc[]

include::features/com.tngtech.jgiven.examples.tags.TagHierarchyExampleTest.asciidoc[]

include::features/com.tngtech.jgiven.examples.userguide.UsingRulesTest.asciidoc[]

16 changes: 16 additions & 0 deletions current/failedScenarios.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
== Failed Scenarios

There are 7 failed scenarios

:leveloffset: -1

include::features/com.tngtech.jgiven.examples.FailingScenarioTest.asciidoc[tag=scenario-failed]

include::features/com.tngtech.jgiven.examples.nested.NestedStepsTest.asciidoc[tag=scenario-failed]

include::features/com.tngtech.jgiven.examples.parameters.ParametrizedScenariosTest.asciidoc[tag=scenario-failed]

include::features/com.tngtech.jgiven.examples.coffeemachine.ServeCoffeeTest.asciidoc[tag=scenario-failed]


:leveloffset: +1
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
=== Failing Scenario

icon:check-square[role=green] 0 Successful, icon:exclamation-circle[role=red] 1 Failed, icon:ban[role=silver] 0 Pending, 1 Total (174ms)

// tag::scenario-failed[]

==== A scenario with a multi line error message

icon:exclamation-circle[role=red] (174ms)

Tags: _FailingOnPurpose_

[unstyled.jg-step-list]
* [.jg-intro-word]*Given* multi line error message icon:exclamation-circle[role=red] (142ms)

.org.opentest4j.AssertionFailedError: [This
[.jg-exception%collapsible]
====
message
has
multiple lines]
Expecting value to be false but was true
....
java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
com.tngtech.jgiven.examples.FailingScenarioTest$Steps.multi_line_error_message(FailingScenarioTest.java:23)
com.tngtech.jgiven.examples.FailingScenarioTest$Steps$ByteBuddy$Vk7bHq4u.multi_line_error_message$accessor$aw89Qi3R(Unknown Source)
com.tngtech.jgiven.examples.FailingScenarioTest$Steps$ByteBuddy$Vk7bHq4u$auxiliary$fjq2kY9Q.call(Unknown Source)
com.tngtech.jgiven.examples.FailingScenarioTest$Steps$ByteBuddy$Vk7bHq4u.multi_line_error_message(Unknown Source)
com.tngtech.jgiven.examples.FailingScenarioTest.a_scenario_with_a_multi_line_error_message(FailingScenarioTest.java:18)
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
com.tngtech.jgiven.junit.JGivenMethodRule$1.evaluate(JGivenMethodRule.java:73)
org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:61)
org.junit.rules.RunRules.evaluate(RunRules.java:20)
org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
org.junit.runners.ParentRunner.run(ParentRunner.java:413)
org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:108)
org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58)
org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:40)
org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:60)
org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:52)
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
org.gradle.api.internal.tasks.testing.worker.TestWorker$2.run(TestWorker.java:176)
org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129)
org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100)
org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60)
org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)
org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:113)
org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:65)
worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)
....
====


// end::scenario-failed[]

Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
=== Attachments Example

icon:check-square[role=green] 7 Successful, icon:exclamation-circle[role=red] 0 Failed, icon:ban[role=silver] 0 Pending, 7 Total (184ms)

// tag::scenario-successful[]

==== Attachments can be added to steps

icon:check-square[role=green]

[unstyled.jg-step-list]
* [.jg-intro-word]*Given* some text content [.jg-argument]_"Hello World"_

* [.jg-intro-word]*Then* it can be added as an attachment to the step with title [.jg-argument]_Hi_

// end::scenario-successful[]

// tag::scenario-successful[]

==== Attachments can be directly shown

icon:check-square[role=green] (9ms)

[unstyled.jg-step-list]
* [.jg-intro-word]*Given* an oval circle

// end::scenario-successful[]

// tag::scenario-successful[]

==== Attachments work with data tables

icon:check-square[role=green] (4ms)

[unstyled.jg-step-list]
* [.jg-intro-word]*Given* some text content [.jg-argument]*<content>*

* [.jg-intro-word]*Then* it can be added as an attachment to the step with title [.jg-argument]*<title>*

.Cases
[.jg-casesTable%header,cols="h,1,1,>1"]
|===
| # | content | title | Status
| 1 | "Hello World" | English | SUCCESS
| 2 | "Hallo Welt" | German | SUCCESS
| 3 | "你好世界" | Chinese | SUCCESS
|===

// end::scenario-successful[]

// tag::scenario-successful[]

==== Inline attachments can be used when having multiple cases

icon:check-square[role=green] (15ms)

===== Case 1

====
color = blue
====

[unstyled.jg-step-list]
* [.jg-intro-word]*Given* a [.jg-argument]_blue_ oval circle

===== Case 2

====
color = red
====

[unstyled.jg-step-list]
* [.jg-intro-word]*Given* a [.jg-argument]_red_ oval circle

// end::scenario-successful[]

// tag::scenario-successful[]

==== Large attachments can be zoomed

icon:check-square[role=green] (51ms)

[unstyled.jg-step-list]
* [.jg-intro-word]*Given* a large oval circle

// end::scenario-successful[]

// tag::scenario-successful[]

==== Steps can have multiple attachments

icon:check-square[role=green]

[unstyled.jg-step-list]
* [.jg-intro-word]*Given* some text content [.jg-argument]_"Hi There"_

* [.jg-intro-word]*Then* it can be added as an attachment multiple times to the step

// end::scenario-successful[]

// tag::scenario-successful[]

==== Thumbnails are shown when not drawn

icon:check-square[role=green] (102ms)

[unstyled.jg-step-list]
* [.jg-intro-word]*Given* an oval circle as thumbnail

// end::scenario-successful[]

Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
=== J Unit Params Serve Coffee

icon:check-square[role=green] 1 Successful, icon:exclamation-circle[role=red] 0 Failed, icon:ban[role=silver] 0 Pending, 1 Total (3ms)

// tag::scenario-successful[]

==== Buy a coffee

icon:check-square[role=green] (3ms)

[unstyled.jg-step-list]
* [.jg-intro-word]*Given* a coffee machine +
_+++An empty coffee machine that is already turned on.<br>The coffee price is set to 2 EUR.+++_

* [.jg-intro-word]*And* there are [.jg-argument]*<coffees>* coffees left in the machine +
_+++The number of coffees in the machine is set to the given value.+++_

* [.jg-intro-word]*And* the machine is [.jg-argument]*<onOrOff>*

* [.jg-intro-word]*And* the coffee costs [.jg-argument]_2_ euros

* [.jg-intro-word]*When* I insert [.jg-argument]*<dollars>* one euro coins

* [.jg-intro-word]*And* I press the coffee button

* [.jg-intro-word]*Then* I [.jg-argument]*<shouldOrShouldNot>* be served a coffee

.Cases
[.jg-casesTable%header,cols="h,1,1,1,1,>1"]
|===
| # | coffees | onOrOff | dollars | shouldOrShouldNot | Status
| 1 | 1 | on | 1 | should not | SUCCESS
| 2 | 1 | on | 2 | should | SUCCESS
| 3 | 0 | on | 2 | should not | SUCCESS
| 4 | 1 | off | 2 | should not | SUCCESS
|===

// end::scenario-successful[]

Loading

0 comments on commit 79e63a8

Please sign in to comment.