diff --git a/editions/tw5.com/tiddlers/concepts/TestCaseTiddlers.tid b/editions/tw5.com/tiddlers/concepts/TestCaseTiddlers.tid new file mode 100644 index 000000000..019ed934f --- /dev/null +++ b/editions/tw5.com/tiddlers/concepts/TestCaseTiddlers.tid @@ -0,0 +1,13 @@ +title: TestCaseTiddlers + + + +Behind the scenes, the templates used to view TestCaseTiddlers use the <<.wlink TestCaseWidget>> widget. + +! Testcase Conventions + +The following conventions are used for testcase tiddlers: + +* `Description` contains a brief description of the test (rendered in inline mode) +* `Output` contains the tiddler text to be rendered. It can also reference other tiddlers +* `ExpectedResult` contains the HTML that should match the rendering of the tiddler `Output` diff --git a/editions/tw5.com/tiddlers/testcases/TestCaseWidget/FailingTest.tid b/editions/tw5.com/tiddlers/testcases/TestCaseWidget/FailingTest.tid new file mode 100644 index 000000000..1ec99f7fb --- /dev/null +++ b/editions/tw5.com/tiddlers/testcases/TestCaseWidget/FailingTest.tid @@ -0,0 +1,11 @@ +title: TestCases/TestCaseWidget/FailingTest +type: text/vnd.tiddlywiki-multiple +tags: [[$:/tags/wiki-test-spec]] +description: An example of a failing test + +title: Output + +The sum is <$text text={{{ [[2]add[2]] }}}/>. ++ +title: ExpectedResult +text: The sum is not 8. diff --git a/editions/tw5.com/tiddlers/testcases/TranscludeWidget/SimpleTransclusion.tid b/editions/tw5.com/tiddlers/testcases/TranscludeWidget/SimpleTransclusion.tid new file mode 100644 index 000000000..7bd92f13e --- /dev/null +++ b/editions/tw5.com/tiddlers/testcases/TranscludeWidget/SimpleTransclusion.tid @@ -0,0 +1,19 @@ +title: TestCases/TranscludeWidget/SimpleTransclusion +type: text/vnd.tiddlywiki-multiple +tags: [[$:/tags/wiki-test-spec]] +description: Simple transclusion + +title: Output + +Good morning, my name is {{Name}} and I live in {{Address}} ++ +title: Name + +Robert Rabbit ++ +title: Address + +14 Carrot Street, Vegetabletown ++ +title: ExpectedResult +text:

Good morning, my name is Robert Rabbit and I live in 14 Carrot Street, Vegetabletown

diff --git a/editions/tw5.com/tiddlers/widgets/TestCaseWidget.tid b/editions/tw5.com/tiddlers/widgets/TestCaseWidget.tid index 8ae7d46fd..aefac685b 100644 --- a/editions/tw5.com/tiddlers/widgets/TestCaseWidget.tid +++ b/editions/tw5.com/tiddlers/widgets/TestCaseWidget.tid @@ -7,18 +7,50 @@ type: text/vnd.tiddlywiki ! Introduction -The testcase widget creates an independent subwiki loaded with the specified payload tiddlers and then renders a specified template from within the subwiki.The default template displays a split view with the source tiddlers on the left and the rendered tiddler titled `Output` on the right. It also displays the tiddler titled `Description` as the heading. This makes it possible to run independent tests that also serve as documentation examples. +The <<.wid testcase>> widget is designed to present interactive example test cases that are useful for learning and testing. It functions by creating an independent subwiki loaded with the specified payload tiddlers and then rendering a specified template from within the subwiki. The <<.wid testcase>> widget can optionally also be used to run and verify test results within the subwiki. -The testcase widget can optionally also be used to run and verify test results within the subwiki. +The default template displays a split view with the source tiddlers on the left and the rendered tiddler titled `Output` on the right. It also displays the tiddler titled `Description` as the heading. This makes it possible to run independent tests that also serve as documentation examples. -The testcase widget creates a lightweight TiddlyWiki environment with the following important limitations: +For example: + +{{TestCases/TranscludeWidget/SimpleTransclusion||$:/core/ui/TestCaseTemplate}} + +!! Features + +The payload tiddlers listed in the tabs on the left are editable, with the results being immediately reflected in the preview pane on the right. However, if the <<.wid testcase>> widget is refreshed then the modifications are lost. + +The green tick at the top left of a testcase indicates it a test has been set up and that it passes. + +If the test fails, then the differences are shown: + +{{TestCases/TestCaseWidget/FailingTest||$:/core/ui/TestCaseTemplate}} + +To be more precise, the rendered HTML output matches the expected test results. + +<$testcase> +<$data title="Description" text="Simple example of a testcase with expected results"/> +<$data title="Output" text="""<$testcase testOutput="Output" testExpectedResult="ExpectedResult"> +<$data title="Description" text="How to calculate 2 plus 2"/> +<$data title="Output" text="<$text text={{{ [[2]add[2]] }}}/>"/> +<$data title="ExpectedResult" text="

8

"/> + +"""/> + + +!! Usage + +The <<.wid testcase>> widget can be used directly as documented below, but it is generally easier and more flexible to create [[TestCaseTiddlers]]. These are special, self contained tiddlers that can contain multiple payload tiddlers making up a testcase. + +! Limitations + +The <<.wid testcase>> widget creates a lightweight TiddlyWiki environment that is a parasite of the main wiki. Because it is not a full, independent TiddlyWiki environment, there are some important limitations: * Output is rendered into a DIV, and so cannot be styled independently of the host wiki -* Any changes to the wiki made interactively by the user are volatile, and are lost when the testcase widget is refreshed +* Any changes to the wiki made interactively by the user are volatile, and are lost when the <<.wid testcase>> widget is refreshed * Startup actions are not supported * Only plugins available in the host wiki can be included in the testcase -The [[Innerwiki Plugin]] offers the ability to embed a fully independent subwiki via an `