Suite for pages in Fitnesse Java - java

Hi i am trying for Test suite pages in Fitnesse.so my page is look like below if i hit suite button it have to suite all link and want to produce result .if i run a paritcular page its working good with Test Page .How suite page works ??
my question is whether we have to create java class for suite page or it automatically import our package in setup it will suite page i read through page but i cant get idea kindly help on this http://www.fitnesse.org/FitNesse.SuiteAcceptanceTests
http://stackoverflow.com/questions/10684735/how-to-include-all-ancestral-setup-pages-in-fitnesse-subwikis
which SuiteAcceptanceTests i have to use??? for my scenario
what I understood is In Setup we have to import our package it wil take care depanding on Folder.
My package is com.xx.xx
Apple
a
b
c
Ball
a
b
c
.....etc
Am Getting Error Like this
Test Summaries
org.apache.velocity.exception.MethodInvocationException: Invocation of method 'execute' in class fitnesse.responders.run.TestResponder$TestExecutor threw exception java.lang.StackOverflowError at suitePage.vm[line 23, column 15]
org.apache.velocity.runtime.parser.node.ASTMethod.handleInvocationException(ASTMethod.java:261)
org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:187)
org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:280)
org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:369)
org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:342)
org.apache.velocity.runtime.directive.Parse.render(Parse.java:260) org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:207)
org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:342)
org.apache.velocity.Template.merge(Template.java:356)
org.apache.velocity.Template.merge(Template.java:260)
fitnesse.html.template.HtmlPage.render(HtmlPage.java:80)
fitnesse.responders.run.TestResponder.doSending(TestResponder.java:69)
fitnesse.responders.ChunkingResponder.startSending(ChunkingResponder.java:66)
fitnesse.http.ChunkedResponse.sendTo(ChunkedResponse.java:25)
fitnesse.FitNesseExpediter.sendResponse(FitNesseExpediter.java:94)
fitnesse.FitNesseExpediter.start(FitNesseExpediter.java:46)
fitnesse.FitNesseServer.serve(FitNesseServer.java:24)
fitnesse.FitNesseServer.serve(FitNesseServer.java:17)
fitnesse.socketservice.SocketService$ServerRunner.run(SocketService.java:99)
java.lang.Thread.run(Thread.java:745)

From the exception stack trace, it looks pretty similar to the Github discussion here.
A page that includes itself, for example, in the content.txt of page .SuitePage.TestPage, you have
!include .SuitePage.TestPage
This can cause the StackOverflowError you see. Check your !includes carefully and see whether it fixes your problem.

Related

Unable to write a simple step passing a single string as a parameter

I work with JBehave on a daily basis, but have been tasked with working on a project that uses Cucumber. In order to add a custom reporting class functionality to that project, I need to add two steps, one at the start of the feature (story) and another at the start of the scenario. I merely want to pass to the application a description of the feature/story and the scenario to be passed to the reporting module. I know that cucumber can access the scenario name through code, but that would only resolve one of the two lines - I would still need to have another one that passes the description of the feature/story.
What I've tried in the feature file:
Feature: Ecolab BDD Test Automation Demo
Scenario Outline: User can login and logout from the landing page
Given story "EcolabWebDemo_TestCases - Ecolab BDD Test Automation Demo"
Given scenario "User can login and logout from the landing page"
Given I am on the Ecolab landing page
The corresponding code for the two added Given statements at the beginning above:
#Given("^story {string}$") // \"(\\S+)\"
public void givenStory(String storyName) {
test.initStory(storyName); // will show on report in Features column
}
#Given("^scenario {string}$") // \"(\\S+)\"
public void givenScenario(String scenarioName) {
test.initScenario(scenarioName);
}
The commented regex patterns afterwards are the suggested ones I should try but do not seem to work either.
The current configuration at least seems to "find" the steps but reports:
cucumber.runtime.CucumberException:
java.util.regex.PatternSyntaxException: Illegal repetition near index
13 ^the scenario {string}$
So that's obviously not the solution. The regex used instead of {string} simply does not find a match and does not run.
regex is absolute Greek to me, not sure why it can't just be simple like the {string} option implied it would be in the cucumber documentation. I've been searching on-line for guidance for the better part of two days to no avail, I'm apparently not even sure what to be searching for.
Based on Grasshopper's suggestion, I updated the version of Cucumber from 1.2.0 to 1.2.5. I was prepared to change the pom.xml to use the 3.x versions but tried the latest of the specified libraries first, and it did report after an attempted run what the correct regex should be for the two steps I added.
#Given("^story \"([^\"]*)\"$")
and
#Given("^scenario \"([^\"]*)\"$")
Now that the project has a version that seems to recognize strings and also reports the missing steps, the project now runs as intended.
Thanks for your help, Grasshopper.

FitNesse getting the suite name in SuiteSetUp java Class

I have 2 pages a Suite page Suite1 and a SuiteSetUp page. Inside the suiteSetUp page I am calling a java constructor with the suite name as parameter.
now When I run my fitnesse suite I am getting the string 'SuiteSetUp' in java. I should get Suite1.. is it doable in FitNesse using java?
!|library |
|suite set up|${USERNAME}|${suiteName}|
suiteName is defined in a template which is included to this page
suiteName is defined as follows.
!define suiteName {${RUNNING_PAGE_NAME}}
this is how I included the template to the page the !define command is written inside the template page
!include -c .FrontPage._TEMPLATE
I guess you include the template page in the SuiteSetUp page, which means the RUNNING_PAGE_NAME will be "SuiteSetUp", thats why you are getting that value. (ok it may sound like I did not say anything... but that's a simple fact).
You can switch to RUNNING_PAGE_PATH or PAGE_PATH and perform string manipulation to retrieve the last token in java if you want to do it in a similar way.

HtmlUnit won't open a link unless I manually tell it to

This works:
HtmlPage page = (HtmlPage) browser.getPage("http://www.somewebsite.com/viewprofile.aspx?profile_id=107992814")
However if I put the URL in a variable like this:
String userPage = "http://www.somewebsite.com/" + profileAnchorLink.getHrefAttribute();
page = (HtmlPage) browser.getPage (userPage);
I get an error that starts off like this
Exception in thread "main" ======= EXCEPTION START ========
Exception class=[net.sourceforge.htmlunit.corejs.javascript.WrappedException]
com.gargoylesoftware.htmlunit.ScriptException: Wrapped com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot read property "data" from undefined (https://www.gstatic.com/swiffy/v7.3.2/runtime.js#72)
Any ideas? I had an html web bot that worked beautifully but then I upgraded to Windows 10 and went through some messy problems, not sure if that has anything to do with it. I made a new project and re-imported the HtmlUnit libraries in case something was broken (kept the same workspace though not sure if that matters) and still to no avail.
The even weirder part is that sometimes it actually works. Initially my program wasn't even using the URL it was just going directly to the link but then something broke so I tried to do things a different way, the URL method was actually working but then it started to work only sometimes and now it doesn't work at all.
So I'm really quite lost on what's going on here.
Seems like the real problem was that I wasn't using getPage properly, after implementing the information from this answer (How to call getPage from HtmlUnit WebClient and have setTimeout not wait forever?) all is well...for now.

How do I open a new project and perspective in SWTBot plug-in test?

For example: I want to "test" Eclipse-CDT. I can't do it using Java code so I need to import a C-project. I didn't found it in Run Configurtion therefore I:
* Create SWTBot Test Plug-in
* Record a sequence of actions via SWTBot Test Recorder:
** Import a C-project
** Change perspective
** Do stuff (run program and check registers for exapmles)
* Insert recorded actions into #Test method
* Run As > SWTBot Test
Here is a problem. SWTBot fails at picking imported project showing various changing errors (mostly "WidgetNotFoundException" at expanding package view or picking imported project from project tree and "NullPointerException" at the same point). Testing code looks like
#Test
public void test() {
bot.menu("File").menu("Import...").click();
bot.tree().expandNode("General").getNode("Existing Projects into Workspace").select();
bot.button("Next >").click();
bot.comboBox().setText("C:\\Sandbox\\JavaWorkspace\\CDTtest");
bot.button("Browse...").click();
bot.button("Finish").click();
bot.toolbarButtonWithTooltip("&Restore").click();
bot.tree().getTreeItem("CDTtest").getNode("main.c").select();
bot.menu("Project").menu("Build Project").click();
bot.menu("Run").menu("Debug").click();
bot.tree().getTreeItem("General Registers").expand();
bot.menu("Run").menu("Step Over").click();
}
Is there more appropriate way to described things? Or maybe a more appropriate tool for that?
It seems like the generated code doesn't include anything about switching to another property. It's possible that there is no recording rule existing for this action. You may need to tweak your test manually to add this missing operation.

Syntax error results in blank page

I am new to wicket and trying to get some things working.
One thing that annoys me a lot is that I get a blank (0 chars of text) page whenever there is a syntax error on a page.
Striped down example:
Test.html
header stuff: doctype ... html ... head ... body ...
<span wicket:id="msgTest" id="message">MSG</span>
footer stuff: /body ... /html
Test.java
public class Test extends WebPage {
public Test() {
add(new Label("msgTest", "Hello, World!"));
}
}
This will output the page as expected.
Now, lets introduce an error:
header stuff: doctype ... html ... head ... body ...
<span wicket:id="msgTest2" id="message">MSG</span>
footer stuff: /body ... /html
I changed the label-id to something different then what the source-file expects.
If I run this code I get the already mentioned blank page.
However, for every request to a page with such a syntax error I get an error report in the log-file of around 1000+ lines. This error-report is basically just wicket-generated html of a page which describes the error.
This makes me wonder why wicket isn't displaying the error-stuff instead of the blank page. I'm not very experienced with wicket but to me it somehow looks like wicket is having trouble rendering its own error-page code.
It would be nice to know how one goes about finding syntax-errors with wicket.
Reading through a 1000+ line error-report for a small error like a misplaced character seems a bit tedious.
Thanks in advance for guiding me into the right direction :)
PS:
wicket-version: 1.4.9
stage: development
I can not confirm that behavior. I went to http://wicket.apache.org/quickstart.html and created a quickstart. Changed the wicket id from 'message' to 'message1' and got a nice descriptive page in jetty:
WicketMessage: Unable to find component with id 'message' in [Page class = com.mycompany.HomePage, id = 0, version = 0]. This means that you declared wicket:id=message in your markup, but that you either did not add the component to your page at all, or that the hierarchy does not match.
How did you create your project?
What I like to do is write unit tests with WicketTester to at least verify that things render, and usually also write assertions to check the components. Something along the lines of
#Test
public void testMessageLabel(
WicketTester tester = new WicketTester();
tester.startPage(Test.class);
tester.assertLastRenderedPage(Test.class);
tester.assertComponent("msgTest", Label.class);
tester.assertLabel("msgTest", "Hello, World!");
)
Then if as in your example the code contains "msgTest" and the html contains "msgTest2" you at least get a test failure instead of seeing it as part of a failing app after deploy.
It's certainly not a complete solution, since this error will make any rendering test for the page fail and the particular failure will just give a long error message in the test result, but at least you don't have to search log files.

Categories