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
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
''Test should be RED in case of missing scenario''
''Each missing scenario increments exceptions counter''
''We are going to run .PowerSlim.SuiteWrongFailedException.TestMissingScenario trough command line''
''The nested run needs its own SLIM_PORT, otherwise it collides with the !-PowerSlim-! instance running this page''
''The nested run uses a TCP port (SLIM_PORT) instead of stdin/stdout, which keeps that transport tested''
-!|script|
|check|eval|java -jar fitnesse-standalone.jar -o -p 8023 -c "PowerSlim.SuiteWrongFailedException.TestMissingScenario?test&format=text&SLIM_PORT=8091"|=~/R:0.+W:0.+I:0.+E:2/|
*!
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ Note: The test pages themselves are disabled in the suite, which makes sure they
|check |eval |$page1.testResults.result.content |=~/@NEXT_EXCEPTION/ |
|check |eval |$page2.testResults.result.content |=~/@PROOF_TESTING_STOPPED/ |

|scenario|To prove test page ignored after _|TESTPAGE, IGNORED, PROOF |
|$URL= |eval |'@TESTPAGE?test' |
|eval |$results = Run-Test '$URL' |
|check |eval |$results.testResults.result.content -match '@IGNORED'|True |
|check |eval |$results.testResults.result.content -match '@PROOF' |True |

******!

The following tests show how normal exceptions are now handled. The error details are returned to !-FitNesse-! and displayed as an exception - neither a success or failure - and testing continues.
Expand All @@ -50,6 +56,16 @@ To abort a test or a suite the developer can issue a {{{ throw "StopTest" }}} Th
|TESTPAGE |PAGETYPE|FIRST_EXCEPTION |NEXT_EXCEPTION |PROOF_TESTING_STOPPED|
|PowerSlim.OriginalMode.SuiteExceptions.TestCases.AbortExceptionStopTest|test |"fail">__EXCEPTION__:ABORT_SLIM_TEST:Test aborted|"fail">ABORT_TEST_INDICATED:Test not run|"ignore">Test not run|

!| To prove suite pages aborted after failure |
|TESTPAGE |PAGETYPE|FIRST_EXCEPTION |NEXT_EXCEPTION |PROOF_TESTING_STOPPED|
|PowerSlim.OriginalMode.SuiteExceptions.TestCases.AbortExceptionStopSuiteTestPage.AbortExceptionStopSuite|suite |"fail">__EXCEPTION__:ABORT_SLIM_TEST:Suite aborted|"fail">ABORT_TEST_INDICATED:Test not run|"ignore">Test not run|
{{{ throw "StopSuite" }}} answers with ABORT_SLIM_SUITE, so !-FitNesse-! itself skips the rest of the suite (and still runs its tear down).

!| To prove suite pages aborted after failure |
|TESTPAGE |PAGETYPE|FIRST_EXCEPTION |NEXT_EXCEPTION |PROOF_TESTING_STOPPED|
|PowerSlim.OriginalMode.SuiteExceptions.TestCases.AbortExceptionStopSuiteTestPage.AbortExceptionStopSuite|suite |"error">__EXCEPTION__:ABORT_SLIM_SUITE:Suite aborted|"error">ABORT_TEST_INDICATED:Test not run|"ignore">Test not run|

{{{ throw "IgnoreScriptTest" }}} ignores the rest of the script table and {{{ throw "IgnoreAllTests" }}} the rest of the page. The text after a colon, as in {{{ throw "IgnoreScriptTest:reason" }}}, goes to the execution log.
''These checks return True or False: a result that contains an IGNORE tag would make !-FitNesse-! ignore this page as well''

!| To prove test page ignored after |
|TESTPAGE |IGNORED |PROOF |
|PowerSlim.OriginalMode.SuiteExceptions.TestCases.IgnoreScriptTest|"ignore">__EXCEPTION__:IGNORE_SCRIPT_TEST:|"ignore">Test not run[\s\S]*2\+2=4 |
|PowerSlim.OriginalMode.SuiteExceptions.TestCases.IgnoreAllTests |"ignore">__EXCEPTION__:IGNORE_ALL_TESTS: |"This table is ignored"\W+td\W+tr |
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Create the function used to run the tests. It runs the page in a nested !-FitNesse-! through the command line (no HTTP server required) and returns the XML report.
The nested run uses its own SLIM_PORT so it does not collide with the !-PowerSlim-! instance running this page.
The nested run talks to its own !-PowerSlim-! over stdin/stdout, so it never collides with the instance running this page.
|script|
|eval |!-
function global:Run-Test ($page) {
$output = java -jar fitnesse-standalone.jar -o -p 8024 -c "$page&format=xml&SLIM_PORT=8091" | Out-String
$output = java -jar fitnesse-standalone.jar -o -p 8024 -c "$page&format=xml" | Out-String
# [char]60 is the less-than sign; a literal XML declaration in this cell would be parsed as markup by FitNesse
$start = $output.IndexOf([char]60 + '?xml')
if ($start -lt 0) { throw "No XML report for '$page': $output" }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
This test verifies that {{{throw 'IgnoreAllTests'}}} ignores the rest of the page.

Note: This test page is intentionally disabled and run from the ExceptionTestRunner page.

| script |
| eval | throw 'IgnoreAllTests:Nothing to test here' |
| show | eval | "This row is ignored" |

| script |
| show | eval | "This table is ignored" |
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<properties>
<Edit/>
<Files/>
<Properties/>
<RecentChanges/>
<Refactor/>
<Search/>
<Test/>
<Versions/>
<WhereUsed/>
</properties>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
This test verifies that {{{throw 'IgnoreScriptTest'}}} ignores the rest of the script table, and that the next table runs.

Note: This test page is intentionally disabled and run from the ExceptionTestRunner page.

| script |
| show | eval | "This row runs" |
| eval | throw 'IgnoreScriptTest:Not on this machine' |
| show | eval | "This row is ignored" |

| script |
| check | eval | "2+2=$(2+2)" | =~/4/ |
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<properties>
<Edit/>
<Files/>
<Properties/>
<RecentChanges/>
<Refactor/>
<Search/>
<Test/>
<Versions/>
<WhereUsed/>
</properties>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

!|script|Remote|${REMOTE_SERVER}|
|check|eval|$NUM.GetType()|System.Int32|
|check|eval|$DECIMAL.GetType()|System.Int32|
|check|eval|$DECIMAL.GetType()|System.Double|
*!
!* String should be string
!|script|Remote|${REMOTE_SERVER}|
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
''A query table cell can store the value it finds in a symbol (SLIM assign instruction)''
!|Query:Local|@{Name = 'Bob'; Id = 7}|
|Name|Id |
|Bob |$QueryId=|

!|script|
|check|eval|$QueryId|7|
|check|eval|"Id $QueryId"|Id 7|
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0"?>
<properties>
<Edit>true</Edit>
<Files>true</Files>
<Properties>true</Properties>
<RecentChanges>true</RecentChanges>
<Refactor>true</Refactor>
<Search>true</Search>
<Test>true</Test>
<Versions>true</Versions>
<WhereUsed>true</WhereUsed>
</properties>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
''A symbol is also a !-PowerShell-! variable. Its value is never pasted into the code: quotes, $ and ; in it stay text''
!|script|
|$Quoted=|eval|"it's a ""quote"" and `$notAVariable; exit"|
|check|eval|$Quoted|it's a "quote" and $notAVariable; exit|
|check|eval|"[$Quoted]"|[it's a "quote" and $notAVariable; exit]|
|check|eval|'[$Quoted]'|[it's a "quote" and $notAVariable; exit]|
|check|eval|$Quoted.Length|38|

''Symbols keep their type''
!|script|
|$Number=|eval|41|
|check|eval|$Number + 1|42|
|$List=|eval|@(1, 2, 3)|
|check|eval|$List.Count|3|
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0"?>
<properties>
<Edit>true</Edit>
<Files>true</Files>
<Properties>true</Properties>
<RecentChanges>true</RecentChanges>
<Refactor>true</Refactor>
<Search>true</Search>
<Test>true</Test>
<Versions>true</Versions>
<WhereUsed>true</WhereUsed>
</properties>
1 change: 0 additions & 1 deletion FitNesseRoot/PowerSlim/OriginalMode/content.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
!define TEST_SYSTEM {slim}
!define SLIM_PORT (8090)
!define COMMAND_PATTERN (pwsh -NoProfile -NonInteractive -File ./slim.ps1)
!define HOST_VERSION (5\.1|7\.\d+)
!contents -R2 -g -p -f -h
1 change: 0 additions & 1 deletion FitNesseRoot/PowerSlim/SuiteREST/content.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
!define TEST_SYSTEM {slim}
!define SLIM_PORT (8090)
!define COMMAND_PATTERN (pwsh -NoProfile -NonInteractive -File ./slim.ps1)
!contents -R2 -g -p -f -h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
!define TEST_SYSTEM {slim}
!define SLIM_PORT (8090)
!define COMMAND_PATTERN (pwsh -NoProfile -NonInteractive -File ./slim.ps1)
'''Each test in this suite should fail by purpose'''
!contents -R2 -g -p -f -h
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,24 @@ https://powerslim.slack.com

```
!define TEST_SYSTEM {slim}
!define SLIM_PORT (8090)
!define COMMAND_PATTERN (pwsh -NoProfile -NonInteractive -File ./slim.ps1)
```
Requires PowerShell 7+ (`pwsh`) on any platform, or Windows PowerShell 5.1 (use `powershell` instead of `pwsh` in `COMMAND_PATTERN`). PowerShell 2.0–5.0 are no longer supported.

PowerSlim implements [SLIM protocol](https://fitnesse.org/FitNesse/UserGuide/WritingAcceptanceTests/SliM/SlimProtocol.html) version 0.5. FitNesse talks to it over stdin/stdout by default, so no port is needed. Defining `SLIM_PORT` (e.g. `!define SLIM_PORT (8090)`) switches to a TCP port on `127.0.0.1`, as before.

### Symbols
A symbol (`|$name=|eval|...|`) is also a PowerShell variable, so `$name` in code gets its value with its type, and the value is never pasted into the code. FitNesse's text rules still apply where PowerShell would not expand a variable: inside single-quoted strings (`'$name'`), for a name followed by more letters (`"$name_suffix"`) and in command names (`te$name`).

### Aborting and ignoring
`throw 'StopTest'` stops the page and `throw 'StopSuite'` the suite. `throw 'IgnoreScriptTest'` ignores the rest of the script table and `throw 'IgnoreAllTests'` the rest of the page.

### Running the tests
Requires Java 11+ and [Pester](https://pester.dev) 5+.
```
./tests/Invoke-AcceptanceTests.ps1 # FitNesse suites (downloads the pinned FitNesse jar)
./tests/Invoke-AcceptanceTests.ps1 -Shell powershell # same, with Windows PowerShell 5.1 running slim.ps1
Invoke-Pester ./tests # unit tests for the SLIM protocol helpers
Invoke-Pester ./tests # unit tests for slim.ps1 and client.ps1
Invoke-ScriptAnalyzer -Path . -Recurse -Settings ./PSScriptAnalyzerSettings.psd1
```
CI runs all of these on Linux, macOS and Windows (PowerShell 7 and 5.1).
Expand All @@ -40,7 +47,7 @@ Examples are available in the acceptance tests [FitNesseRoot/PowerSlim](https://
### March 1, 2017

* [Fitnesse 20161106](http://fitnesse.org/.FrontPage.FitNesseDevelopment.FitNesseRelease20161106) introduced bracking change. _FitNesse and Slim can now communicate over stdin/stdout. This removes the hassle with network ports [977](https://github.com/unclebob/fitnesse/pull/977)_
You need to set [SLIM_PORT](https://github.com/konstantinvlasenko/PowerSlim/blob/02dc82325d639123874beebbeb5229ba202f867b/FitNesseRoot/PowerSlim/OriginalMode/content.txt#L2) variable to make PowerSlim work again
PowerSlim now supports stdin/stdout, so `SLIM_PORT` is no longer needed.


### October 7, 2016
Expand Down
Loading
Loading