FitNesse Suites Variables - fitnesse

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.

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.

Intellitest code coverage

I am using Intellitest 2015 to do data driven testing. My method is having two parameter
MethodA(List class, string sourceType). When I am running the intellitest, the framework is passing arbitrary arguments such as control characters("\u0007","\u0008","\a" etc etc). I am preventing these strings by adding conditional statement at the top of my method. My Question is that when I am checking each special characters individually the number of block execution and run is more ie(39/87) but when I am adding these in a string[] array and checking all in one shot the number of blocks executing is gradually decreasing(18/87). How can i achieve maximum code block execution here. Can anyone help me on this?
What you are seeing is dynamic code coverage (https://msdn.microsoft.com/library/vs/alm/test/developer-testing/intellitest-manual/input-generation#dynamic-code-coverage).
Please take a look at the following example of applying IntelliTest on a real world application to achieve full coverage: https://blogs.msdn.microsoft.com/visualstudioalm/2015/08/14/intellitest-hands-on/.

SetUp page does not work in 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.

Runtime script evaluation in Grails - Best Practicse

In our application, numerous emails are being sent from the system. These emails were of the same format for all users with different contextual variables populating the dynamic data.
We are now planning a feature to allow administrators to edit and customize these templates. As such the plan is to use the groovy shell to evaluate the templates at run time e.g.
Binding binding = new Binding();
binding.setVariable("model", [var1: "First Name", var2: "Last Name"])
GroovyShell shell = new GroovyShell(binding);
Object email = shell.evaluate('return "<html><title>Test Shell</title><body>${model.var1} ${model.var2}</body></html>";');
This seems to work adequately for us. The questions I have are:
Is the GroovyShell the preferred engine to use or is Rhino or other better?
Are there any performance concerns or memory issues to be aware of? Any low hanging fruit we can optimize i.e. can the shell or binding be reused
What's the biggest bottleneck in the above code? The construction? The evaluation?
thanks
I would recommend using something like GroovyPagesTemplateEngine because it goes beyond just Groovy eval and you and you can use all the grails taglib goodness as well. I'm using both GroovyPagesTemplateEngine and SimpleTemplateEngine for your exact scenario.
SimpleTemplateEngine is slightly faster so if I don't need much more than simple binding I use it. When I need to deal with logic and control structures, I use GroovyPagesTemplateEngine.
For grails, use the page rendering api instead. http://grails.org/doc/2.0.x/guide/introduction.html#whatsNew

statically analysing Lua code for potential errors

I'm using a closed-source application that loads Lua scripts and allows some customization through modifying these scripts. Unfortunately that application is not very good at generating useful log output (all I get is 'script failed') if something goes wrong in one of the Lua scripts.
I realize that dynamic languages are pretty much resistant to static code analysis in the way C++ code can be analyzed for example.
I was hoping though, there would be a tool that runs through a Lua script and e.g. warns about variables that have not been defined in the context of a particular script.
Essentially what I'm looking for is a tool that for a script:
local a
print b
would output:
warning: script.lua(1): local 'a' is not used'
warning: script.lua(2): 'b' may not be defined'
It can only really be warnings for most things but that would still be useful! Does such a tool exist? Or maybe a Lua IDE with a feature like that build in?
Thanks, Chris
Automated static code analysis for Lua is not an easy task in general. However, for a limited set of practical problems it is quite doable.
Quick googling for "lua lint" yields these two tools: lua-checker and Lua lint.
You may want to roll your own tool for your specific needs however.
Metalua is one of the most powerful tools for static Lua code analysis. For example, please see metalint, the tool for global variable usage analysis.
Please do not hesitate to post your question on Metalua mailing list. People there are usually very helpful.
There is also lua-inspect, which is based on metalua that was already mentioned. I've integrated it into ZeroBrane Studio IDE, which generates an output very similar to what you'd expect. See this SO answer for details: https://stackoverflow.com/a/11789348/1442917.
For checking globals, see this lua-l posting. Checking locals is harder.
You need to find a parser for lua (should be available as open source) and use it to parse the script into a proper AST tree. Use that tree and a simple variable visibility tracker to find out when a variable is or isn't defined.
Usually the scoping rules are simple:
start with the top AST node and an empty scope
item look at the child statements for that node. Every variable declaration should be added in the current scope.
if a new scope is starting (for example via a { operator) create a new variable scope inheriting the variables in the current scope).
when a scope is ending (for example via } ) remove the current child variable scope and return to the parent.
Iterate carefully.
This will provide you with what variables are visible where inside the AST. You can use this information and if you also inspect the expressions AST nodes (read/write of variables) you can find out your information.
I just started using luacheck and it is excellent!
The first release was from 2015.

Resources