The scripttable of fitnesse can only execute all rows in sequence. This blog post describes how to enable scripttable to support if-then to execute one row in conditions.
First, let's popularize the concept. What isFitnesseLet's hear about the. Net version of Cucumber's founder asak helles ø y.FitnesseComparison with cucumber:
Fit/FitnesseAnd cucumber both perform acceptance tests written in advanced languages. Fit only recognizes HTML, while fitnesse simplifies the process of writing tests by providing wiki syntax. In fit/fitnesse, all tests are presented as tables.
Fitnesse has the advantage of Wiki support over cucumber.
After fitnesse is extended, the Wiki text of if-then is used in scripttable:
! Path classes! Path lib/*. Jar! Define test_system {slim }! | Import | fitnesse. fixtures | library | echo fixture | script | check | echo | 1 | 0 <_ <2 | ensure | echo | true | reject | echo | false | $ true = | echo | true | $ false = | echo | false | show | echo | $ true | show | echo | $ false | ''' $ t? ''' Indicates that if the value of the variable $ t is true, the row is executed. Otherwise, ''' $ f !? ''' Indicates that if the value of the variable $ F is false, the row is executed. Otherwise, note: $ T must be assigned a value in the first scripttable, can $ t be used in the second scripttable? And $ T !? | Script | show | echo | 112233 | $ true? | $ T1 = | echo | true | check | echo | $ T1 | true | $ true !? | $ T2 = | echo | false | check not | echo | $ T2 | false | $ false !? | $ F1 = | echo | false | check | echo | $ F1 | false | $ false? | $ F2 = | echo | true | check not | echo | $ F2 | true |
Note:
| $true? | $t1= | echo | true |
Explanation: if ($ true) then $ T1 = true
| $true!? | $t2= | echo | false |
Explanation: If (! $ True) then $ T1 = false
Note:
However, $ t can only be used in the next scripttable after $ t is assigned to the first scripttable? And $ T !?,
In another way: in the same scripttable, after $ t is assigned a value, $ t? New values cannot be obtained in time.
Test results:
Modify one fitnesse source file:
Fitnesse/src/fitnesse/testsystems/slim/Tables/scripttable. Java
The specific modification code can be viewed in http://git.oschina.net/fitneesefan/FitnesseKit/commit/99240ecb915e007c11761cf29036c46465b112f2#diff-5.
Let's briefly record it. If an enthusiastic audience wants to know more details, I would like to explain it further.
Extends the scripttable of fitnesse: If-then is supported.