SetUp page does not work in FitNesse - fitnesse

We have a setup like the following created with FitNesse for test automation:
MainPageSuite
SetupPage
ChildPage1Suite
SetupPage
Test
ChildPage2Suite
SetupPage
Test
We would like to use the SetupPage(s) to define the variables that need to be used. Currently when having the variables defined on the SetupPage(s) they are not functioning. When we just define them directly in the Test page they do work.
When the variabales are on the SetupPage we receive the following error:
fit:fit.FitServer Date: 9:06:22 AM (CEST) on donderdag, april 3, 2014
Test
Page: .MainPageSuite.ChildPage1Suite.Test
Command: java -cp fitnesse.jar;defaultPath fit.FitServer BDACCTEST
51439 3863 Exit code: 1 Time elapsed: 1.046 seconds
Standard Error: Error: Could not find or load main class fit.FitServer
The following variables were defined:
variable defined: TEST_SYSTEM=slim
variable defined: COMMAND_PATTERN=%m -r fitSharp.Slim.Service.Runner,c:\FitNesse\dotnet2\fitsharp.dll %p
variable defined: TEST_RUNNER=c:\FitNesse\dotnet2\Runner.exe
Does anyone have an idea what is wrong with our structure causing the SetupPage(s) not to work?

Add the variables to the root page of the Slim tests. This could be the root of the FitNesse wiki (e.g., localhost:8080/root) if we're only doing Slim tests, or on the Slim test page or suite page if we have a mix of Slim and Fit tests in the wiki.
You may have Java paths defined. Make sure the FitNesse root (e.g., localhost:8080/root) and any other pages don't contain Java paths. If you find the following, remove them.
!path classes
!path fitnesse.jar
!path fitlibrary.jar
From http://fitsharp.github.io/Slim/GettingStarted.html
If these variables are in the set up page, FitNesse is already processing the page as a Fit Java page before it reads them, instead of a Slim .NET page.

Related

FitNesse use global variables to load included pages

was wondering if it is possible to allow global variables like ${PAGE_NAME} be a part of an include?
We have different teams using different feature environments (and more environments coming up) which uses symlinks and includes to environment setup pages. At the moment we're copying everytime the literal path. It is less error prone when we can use the global variables FitNesse has to offer.
For example a simple setup:
root
.Env
.FEAT1 --> connection details to setup/connect env 1.
.FEAT2 --> connection details to setup/connect env 2.
.FEAT300 --> connection details to setup/connect env 300.
.Team1
.FEAT2 --> uses !include -seamless .Env.FEAT2 and uses a symlink to suiteX
.Team10
.FEAT300 --> uses !include -seamless .Env.FEAT300 and uses symlinks to suiteX, suiteB and suiteC
etc
When using include -seamless .Env.${PAGE_NAME} it does not load the include. Preferably we want to use the variables FitNesse offers, but I'm sure we are doing something wrong or using the wrong syntax.
Any suggestions on how to use the global variables in a way we try to achieve?
I tried an other solution by defining the whole include into a variable, but that has unfortunately the same result:
!define includes {!include -seamless .Env.${PAGE_NAME} }
$includes
Writing down the global var itself resolves as expected.

How to set Fitnesse variables in query string

I'm currently setting up Fitnesse, with FitSharp and the .net implementation of dbfit.
I understand how to trigger tests or suites from the submission of a URL, or from a command line, eg:
java -jar fitnesse-standalone.jar -c "MyTest?test&format=text"
What I can't figure out is how to submit variable values in this query string.
So, if I have a test containing a Sql statement which has a Fitnesse variable referenced in the Where clause, and the value of this variable is defined in a sibling static page, I would like to be able to run this test from the command line and submit a value for this variable which overrides the value in the static page. Something like:
java -jar fitnesse-standalone.jar -c "MyTest?test&format=text&${myVar}=abc"
Is this possible at all?
Thanks
Mark
There are two ways to pass variables from the command line, both involving environment variables.
(1) Define an environment variable (or identify one that already exists). You can use general purpose system variables (like %TMP% or %HOMEPATH%) or your own user-defined variables (e.g. %JAVA_HOME%) or create your own. My short Fitnesse launcher (a .CMD file) is this:
set SEED=%RANDOM%
set FITNESSE_PORT=9999
java -jar fitnesse-standalone.jar -p %FITNESSE_PORT% -e 0
The FITNESSE_PORT variable is defined just for use in the very next line. The SEED variable, however, does magic: it allows several people to run the same test simultaneously by generating unique values per session. (This assumes that each user runs their own FitNesse server, so each will thereby have a unique session.) I then instrument my tests by defining ids relative to the seed, e.g.
!define TestClient (MyTestClient_${SEED})
(2) Pass an environment variable setting scoped to just the java process that instantiates the FitNesse runner. This technique gives you precisely the same results with just a different implementation:
java -DSEED=%RANDOM% -jar fitnesse-standalone.jar -p %FITNESSE_PORT% -e 0
This yields precisely the same result within FitNesse, giving you access to the %SEED% environment variable as ${SEED}.
For more, see part 2 of my seven-part series on Acceptance Testing with FitNesse published on Simple-Talk.com.

Using jmockit with FitNesse

I'm having trouble getting FitNesse to play nice with jmockit.
I'm using version v20110104 of FitNesse and version 0.999.9 of jmockit.
I had some ClassDefNotFound exceptions being thrown, but those were solved by adding the following to my FitNesse root:
!define COMMAND_PATTERN {java -javaagent:../lib/jmockit.jar}
Which is the location of my jmockit jar. However, now my tests that use jmockit hang in the "running" state, never to return.
I asked around on some FitNesse boards, and tried altering the command pattern like so:
!define COMMAND_PATTERN {java -javaagent:../lib/jmockit.jar -cp %p %m}
This defines the classpath (%p represents all defined path variables and %m represents the main java method)
This prevents the test from hanging, but I get a new exception:
java.lang.IllegalStateException: Invalid context for the recording of expectations
I can't find much information about this exception.
Has anyone gotten the latest release of jmockit to work with FitNesse?
This link may help you: http://tech.dir.groups.yahoo.com/group/fitnesse/message/17815
Are you using jmockit inside the fixtures, or how? What purpose? I'm just curious, had never needed to mock anything in my acceptance tests.

Cucumber errors suppressed (not displayed fully)

I just installed cucumber, and I tested it. I got the following error:
teefcomp:cucumber-intro teef$ cucumber features/manage_users.feature
Using the default profile...
F----F
Failing Scenarios:
cucumber features/manage_users.feature:6 # Scenario: User List
1 scenario (1 failed)
4 steps (4 skipped)
0m0.029s
It seems to be suppressing the error. I was expecting something like:
Feature: Manage users
In order to understand my user base better
As an administrator
I want to view a list of users
Scenario: User List
Given I have users named George, Mary
uninitialized constant User (NameError)
./features/step_definitions/user_steps.rb:3
./features/step_definitions/user_steps.rb:2:in '/^I have users named (.*)$/'
features/manage_users.feature:7:in 'Given I have users named George, Mary'
Anyone know how to get cucumber to display the errors in full?
--backtrace, --verbose, -b and --trace do not work; I still see F----F and the failing scenario is listed, but I still expect something like description on the "NameError" line. Is this a feature of an older version of cucumber? (I'm using screencasts to start using cucumber.)
running with the -b flag should give you a full backtrace
cucumber features/manage_users.feature -b
EDIT:
Additionally, you can use the full notation of --backtrace. If you are running via rake, run with the --trace flag
to get full output, you can use the --format flag. I generally use --format pretty to get a line-by-line walk through.
from the --help output.
-f, --format FORMAT How to format features (Default: pretty). Available formats:
debug : For developing formatters - prints the calls made to the listeners.
html : Generates a nice looking HTML report.
json : Prints the feature as JSON
json_pretty : Prints the feature as pretty JSON
junit : Generates a report similar to Ant+JUnit.
pdf : Generates a PDF report. You need to have the
prawn gem installed. Will pick up logo from
features/support/logo.png or
features/support/logo.jpg if present.
pretty : Prints the feature as is - in colours.
progress : Prints one character per scenario.
rerun : Prints failing files with line numbers.
stepdefs : Prints All step definitions with their locations. Same as
the usage formatter, except that steps are not printed.
tag_cloud : Prints a tag cloud of tag usage.
usage : Prints where step definitions are used.
The slowest step definitions (with duration) are
listed first. If --dry-run is used the duration
is not shown, and step definitions are sorted by
filename instead.
Use --format rerun --out features.txt to write out failing
features. You can rerun them with cucumber #rerun.txt.
FORMAT can also be the fully qualified class name of
your own custom formatter. If the class isn't loaded,
Cucumber will attempt to require a file with a relative
file name that is the underscore name of the class name.
Example: --format Foo::BarZap -> Cucumber will look for
foo/bar_zap.rb. You can place the file with this relative
path underneath your features/support directory or anywhere
on Ruby's LOAD_PATH, for example in a Ruby gem.
If your application is a Rails app, you can use the #allow-rescue tag for the scenario-of-interest, then your rails test_log will include more details about where in your application the error was originally raised.
From the command line you can quickly look at the end of the test log with tail -n200 log/test_log.rb (adjust the number of lines to see the portion of interest).

FitNesse Suites Variables

I'm working with FitNesse and the first time trying with Suite.
I had my test scripts in many parts as I was receiving Jave Heap errors.
Now I'd thought try using suites.
I have a Fitnesse module that load many variables. This module was included in each Part of the suite so I tried to use this variable module just at the beginning of the suite using the !see function.
Unfortunatly the variables aren't stored and used for the pages in the suite.
How can I pass down the variables?
eg. the variables from VariablesSetUp do not pass down to the other pages.
!see .FitNesse.VariablesSetUp
!see .FitNesse.TestDate1
!see .FitNesse.TestDate2
!see .FitNesse.TestDate3
This is a bit tricky to explain; let me know if I haven't made myself clear.
Cheers
Welcome to Stack Overflow!
I think you want to use the !include markup. Using !include -c PagePath will insert the given page (!define values and all) into the current one.

Resources