0

Looking for a solution to convert Fit fixture for FitNesse test to Slim.

I got the Command-Line Fit fixture.

Since all my Fitnesse test system is running on Slim I need to have CommandLineFixture as Slim to execute bash script from my test.

Any other workaround for this should work for me.

I am trying to execute a script from FitNesse test and this script writes some text in file present in a server where my Fitnesse server is running.

But what I am observing with the provided fixture its opening file and not writing any text into it.

So just wanted to check do we have any constraint with Fitnesse to execute a script which writes into a file.

Also, I have given all rwx permission to the text file

Below is my modified script:

!define TEST_SYSTEM {slim} 
!path ../fixtures/*.jar  
|Import                                            |  
| nl.hsac.fitnesse.fixture.slim.ExecuteProgramTest | 
|script                                            | 
|set    |-c            |as argument|0              |  
|set    |ls -l /       |as argument|1              |  
|execute|/bin/bash                                 |  
|check  |exit code     |0                          |  
|show   |standard out                              |  
|check  |standard error|!--!                       |

Executing the above test fetched no response and gives the result as:

Test Pages: 0 right, 0 wrong, 1 ignored, 0 exceptions

Assertions: 0 right, 0 wrong, 0 ignored, 0 exceptions

(0.456 seconds)

n-verbitsky
  • 552
  • 2
  • 9
  • 20
  • I believe you have to remove the '.ExecuteProgramTest' from the line below import. Then a blank line must be added above the line with 'script' and at the end of the line with script should become `|script|ExecuteProgramTest|` . That should fix the test. – Fried Hoeben Feb 23 '17 at 17:30
  • Thank you for patiently helping me out of this. – vipin sahu Feb 23 '17 at 21:47
  • If it helped can you accept my answer? – Fried Hoeben Feb 24 '17 at 06:29

1 Answers1

0

I had a helper method to start a program in my my fixture library already, but I started work on fixture today. Would the execute program test fixture work for you?

Example usage:

We can run a program with some arguments, check its exit code and show its output.

|script |execute program test        |
|set    |-c            |as argument|0|
|set    |ls -l /       |as argument|1|
|execute|/bin/bash                   |
|check  |exit code     |0            |
|show   |standard out                |
|check  |standard error|!--!         |

The default timeout for program execution is one minute, but we can set a custom timeout. Furthermore we can control the directory it is invoked from, set all arguments using a list and get its output 'unformatted'.

|script               |execute program test           |
|check                |timeout           |60000       |
|set timeout of       |100               |milliseconds|
|set working directory|/                              |
|set                  |-c, ls -l         |as arguments|
|execute              |/bin/bash                      |
|check                |exit code         |0           |
|show                 |raw standard out               |
|check                |raw standard error|!--!        |

The timeout can also be set in seconds, and pass environment variables (and the process's output is escaped to ensure it is displayed properly).

|script        |execute program test           |
|set timeout of|1              |seconds        |
|set value     |Hi <there>     |for        |BLA|
|set           |-c             |as argument|0  |
|set           |!-echo ${BLA}-!|as argument|1  |
|execute       |/bin/bash                      |
|check         |exit code      |0              |
|check         |raw standard out               |!-Hi <there>
-!|
|check|standard out|{{{Hi <there>
}}}|
Fried Hoeben
  • 3,247
  • 16
  • 14
  • I have used provided library which didnt work. Below is script that I am trying to execute:!define TEST_SYSTEM {slim} !path /home/fixtures/hsac-fitnesse-fixtures-2.11.1-SNAPSHOT.jar |Import | | nl.hsac.fitnesse.fixture.slim.ExecuteProgramTest | than above one of the code provided. – vipin sahu Feb 21 '17 at 22:01
  • As far as I'm aware the import table should only contain the package name, not the class. Can you try that? If that doesn't help can you share what error occurs? – Fried Hoeben Feb 22 '17 at 05:47
  • And I believe you'll need to add more jars to the path: the dependencies used by the library. I usually do this via the maven-classpath-pluging (e.g. `!pomFile ../pom.xml@compile`), or by having Maven copy all my dependencies to a directory (e.g. fixtures) and then using `!path fixtures/*.jar`. – Fried Hoeben Feb 22 '17 at 06:52
  • Good to know this one. I am trying to execute script from Fitnesse test and this script writes some text in file present in server where my Fitnesse is running. But what I am observing is its opening file and not writing any text into it. So just wanted to check do we have any constraint with Fitnesse to execute a script which writes into a file. Also I have given all rwx permission to file. – vipin sahu Feb 22 '17 at 20:54
  • !define TEST_SYSTEM {slim} !path ../fixtures/*.jar |Import | | nl.hsac.fitnesse.fixture.slim.ExecuteProgramTest | |script | |set |-c |as argument|0| |set |ls -l / |as argument|1| |execute|/bin/bash | |check |exit code |0 | |show |standard out | |check |standard error|!--! | Executing above test fetched no response. and give result as: Test Pages: 0 right, 0 wrong, 1 ignored, 0 exceptions Assertions: 0 right, 0 wrong, 0 ignored, 0 exceptions (0.456 seconds) – vipin sahu Feb 22 '17 at 21:42
  • Can you add this to the question? In a comment without formatting I can't see what is going on. Or maybe post it as issue on the project's GitHub – Fried Hoeben Feb 23 '17 at 05:36
  • Added this to question above – vipin sahu Feb 23 '17 at 16:50