caption: testcase created: 20240507221902644 modified: 20240507221902644 tags: Widgets title: TestCaseWidget type: text/vnd.tiddlywiki ! Introduction 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. This makes it possible to run independent tests that also serve as documentation examples. The <<.wid testcase>> widget can be used directly as documented below, but it is generally easier to create [[TestCaseTiddlers]]. These are special CompoundTiddlers that can contain multiple payload tiddlers making up a test case. !! Features Here is an example of a test case showing the default split view with the source tiddlers on the left and the tiddler titled `Output` rendered on the right. <> Notice also that clicking on links within the output pane will switch to the tab containing that tiddler. The text of the payload tiddlers listed 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 test case indicates that a test has been set up and that it passes. If the test fails, a red cross is shown, and there is a display of the differences between the actual results and the expected results: <> ! 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 <<.wid testcase>> widget is refreshed * Startup actions are not supported * Only plugins available in the host wiki can be included in the test case If these limitations are a problem, the [[Innerwiki Plugin]] offers the ability to embed a fully independent subwiki via an `