Intellij is not running individual Spock tests in Grails any more - grails

My company switched from idea-131 to idea-171 a few months back (which I've been keeping updated ever since). One thing I've noticed is that I can no longer run Spock unit tests individually anymore. Instead, when I right click on a test, it only offers me the ability to run the whole file. That's kind of annoying if a page has 40 tests! Is there a config somewhere that I need to tick?

Nevermind, I answered that question as soon as i asked it! they've moved the option to a little play button headed beside each test method. I'm not a fan of iconicizing little commands but ... there you go.

Related

Running Geb + spock tests headless

I have a number of geb functional tests for a grails application.
The tests are working as expected when executed from terminal or IDE.
Although the tests need to be executed by hudson, so they are run in headless mode using Xvfb.
The problem is that the tests keep failing, or behaving unexpectedly, returning errors like RequiredPageContentNotPresent and Stale Element Reference Exception in places that doesn't make sense.
For example:
(at LicencePage is verified above, and page isn't changed)
when:
addDocument(Data.Test_Doc_name,Data.Test_Doc_file)
sometimes throws
Failure: Add Actual Licence (HomePageSpec)
| geb.error.RequiredPageContentNotPresent: The required page content 'addDocument - SimplePageContent (owner: LicencePage, args: [Functional Test Doc, /var/lib/hudson/jobs/KB-Functional_Tests/workspace/app/../manual_test_data/so_v3/os_test_1], value: null)' is not present
at geb.content.TemplateDerivedPageContent.require(TemplateDerivedPageContent.groovy:61)
at geb.content.PageContentTemplate.create_closure1(PageContentTemplate.groovy:63)
at geb.content.PageContentTemplate.create(PageContentTemplate.groovy:82)
at geb.content.PageContentTemplate.get(PageContentTemplate.groovy:54)
at geb.content.NavigableSupport.getContent(NavigableSupport.groovy:45)
at geb.content.NavigableSupport.methodMissing(NavigableSupport.groovy:121)
at geb.Browser.methodMissing(Browser.groovy:194)
at geb.spock.GebSpec.methodMissing(GebSpec.groovy:51)
at HomePageSpec.Add Actual Licence (HomePageSpec.groovy:228)
The method addDocument() is defined on an 'abstract' page, which LicencePage is extending. In most cases like this, if I copy the method code directly into my Spec, it is going to work, although its ruining all the structure I have on my test pages.
Anyone has experience running geb tests with Xvfb? Have you faced these issues?
All tests are passing when executed locally, and this not a data issue as the DB is always cleared
Also, without making any changes, the tests are behaving non-deterministic (on hudson) so the above exception is not always thrown. Without any changes at all, tests are sometimes successful and sometimes fail.
The description you gave seems to be the symptom of a flackey test-suite. we were facing this problem as well some time ago. A good starting point for this is this presentation (around min. 35) and the documentation about the wait stuff in geb.
If you think, it could have something to do with xvfb (where i have no experiences with), you could try to use phantomjs as the test-runner and check if it works correctly.

Selenium Web Driver Error

I'm getting a weird error while trying to click on a Capybara Element
I'm using find(:xpath,"//a[contains(text(),'Connect')]").click
(find(:xpath,"//a[contains(text(),'Connect')]").present? return true)
the error I get is:
Selenium::WebDriver::Error::MoveTargetOutOfBoundsError Exception: Element cannot be scrolled into view:javascript:void(0);
i did some research and the only solution i found is that setting the selenium version to 2.16 may fix this issue (i'm using 2.25).
anybody got an idea?
It may happen when the page being tested is not fit into the current window size. If you know such pages where usually these error happening, you may explicitly scroll down before doing the operation on such hidden elements(like click, clear etc). Here the code to explicitly scroll down the page.
In java,
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("javascript:window.scrollBy(250,350)");
From the times I used selenium webdriver to test .NET apps, I would get that error when the issue was exactly what it sounds like: It's looking for an object on the page that it cant scroll to for some reason. In my case it was because some dialogue boxes would appear without scrollbars and the driver had no way to "scroll the object into view"
Can you watch the execution of your test and see if that's the case? I had some luck rolling back to a previous version of firefox because 15+ was (as of about 2 months ago when I had the issue) unsupported by web driver and had this problem periodically. Rolling back selenium versions may help too.
First step though is definitely to watch the execution of the test and see whats happening though. And a good debugging idea may be to try to work through your steps manually yourself to make sure the test works by hand.
Its also worth noting that for the webdriver to be able to execute click the object actually has to be visible. IsPresent doesnt require that, it just searches the page files. Also an issue I ran into. IsPresent will still return true for objects that are not and cannot be made visible on the page (i.e. something at the bottom of the page that you cant see at the time)
Couple of tips here:
Webdriver should ideally be on the most recent update, it's what most use (Unless you're doing Ruby Automation)
Use css selectors, xpath (Whilst rendered), is almost always heavier on both resources and code.
Try defensive coding, first of all ascertain it exists. There are many ways to do that dependent on what package you are using. In ruby you would do page.has_css?('css_string')

Fitnesse - runner process not starting

I have a test in fitnesse which used to work, but when I got into work today the test did not start at all. As soon as I press test I get the "0 errors 0 warrings..." text on the top of the test. Looking in the source control software, I can not find any changes to the test, or to anything related to it. I have noticed that the runner process does not start when I run the test. Other tests seem to work fine, and I can copy the tables from the test which is not working into an other test and everything is fine. Any ideas on what could be wrong?
My standard answer in this situation is, "have you checked your classpath?"
I say this, as typically when this sort of thing happens, it is that the !path doesn't point to the stuff you need, whether it be FitNesse.jar or your own custom code.
Also, do you get an output page where you can check the classpath? i doubt it, but that can help diagnose classpath issues.

Running Fitnesse in Debug mode [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I used to use Fitnesse daily years ago, but forgot how to run tests in debug mode (or have stack trace information be output) - does anyone know?
I recall being able to configure it either as a flag when running/starting up fitnesse.jar, or as a URL parameter (e.g. http://localhost:8090/FitLibraryWeb.MyTest?test&debug=true)
To debug fixtures in .Net I normally add Debugger.Break() inside my C# fixture code
Although my prefered development solution has already been pointed out on Rustin's DebugBreak() suggestion, and alternate solution is to invoke RunnerW.exe, which requires adding the following line to your target Fitnesse test page
[[Press me to start in remote debug mode][?responder=test&remote_debug=true]]
Please, bear in mind that I am assuming your test page already defines REMOTE_DEBUG_RUNNER pointing to RunnerW.exe, as stated in Fitnesse guide's Customizing Test Execution section
For the sake of simplicity, I will present a sample fit test header.
So, here is how to Remote Debug using Visual Studio:
Make sure you fitnesse test page starts with the following lines
!define TEST_RUNNER {FitSharp\Runner.exe}
!define REMOTE_DEBUG_RUNNER {FitSharp\RunnerW.exe}
[[Press me to start in remote debug mode][?responder=test&remote_debug=true]]
The rest of your test specification goes here
In Visual Studio, set target code breakpoint
On fit test page, click on Press me to start in remote debug mode, defined above. This starts the RunnerW.exe process (winform app called Fitsharp) which will wait for 30 seconds (I am not sure).
In Visual Studio > Debug menu > Attach to process, locate RunnerW.exe and press Attach button.
On Fitsharp window (RunnerW.exe process), click GO button and you are on your way.
As pratical solution, I use the following strategy:
I create static page called SetupEngine and add the 3 lines stated on previous step 1.
On the top of every test page, I just put the following header, so I don't have to repeat those 3 lines.
!include .SetupEngine
Note that . (dot) on .SetupEngine (which is a path) refers to your Fitnesse root page. You may have to adjust it.
I had this ideia when I was referring to Fitnesse.UserGuide's remote debug section
Hope it helps
Add the following line just before the your test target location
!|debug|
For further details, refer to Michael Sorens' excelent article, the most comprehensive article on Fitnesse debug techniques.
Your thinking of using RunnerW.exe as opposed to the Runner.exe.
If you change your test runner to be RunnerW a pop-up window will appear with a 'go' button on it, and will not start the fitnesse test until you hit it.
Before hitting go you can attach to any process (via 'Attach To Process' in the debug menu if your using VS) and the execution will pause at the break points set.
Note: You must have the same build being used by FitNesse as the code you are debugging.
You can also attach to a remote process, using the Remote Debugger.
Also, if you attach the the RunnerW.exe process, you can debug the fixtures themselves.
I haven't had to do it in a while, but the current documentation that comes with FitNesse indicates that you are close. You should be using remote_debug instead of debug.
The best thing is to start with the documentation that comes with your copy of FitNesse, as it matches what you are running. If you are running on port 8080, then the following link should work: http://localhost:8080/FitNesse.UserGuide.DebugingFixtureCode.
Assuming you are using Java, these instructions should help. If you are using a different language I am not sure I can help.

WSS caches old Workflow version

I'm currently developing three workflows that are supposed to handle the status of items in different lists.
Each Workflow is attached to a separate list.
When I'm deploying and debugging in my development Environment, everything works fine.
Except for the case, when an item is created via an incoming mail.
I already figured out, that I have to restart some services and then it'll work, but I'm still not sure wich of the services is caching the workflow.
Afterwards I build a .wsp file which I deploy on a server.
Each time I deploy the solution, I do a retract and delete solution first.
After deployment I'll recreate the workflows on the lists
It seems to me that this has no effect. An older version of the workflow is still triggered, if I create a new instance in the list.
I already restarted the whole server and still no result.
Has anyone an idea what else I could try in order to get this working?
Thanks in advance.
If Timer Service is the one that calls your code, then restart Windows SharePoint Services Timer (OWSTIMER.EXE).
When workflow waits on something, it gets serialized (hydrated). When event happens, OWSTIMER.EXE deserializes (dehydrates) and continues workflow execution.
So timer is the one that wakes workflow up.
So this problem kind of resolved itself.
I was reading an article on Kirk Evanns Blog on an issue with the development of workflows in VS2008 for WSS.
I had not realized that I still had an illeagle reference in my Project properties.
I removed the reference. The second thing I tried was deploying with -upgradesolution rather than doing a retract-delete-add-deploy...
I don't know which of both did the trick, but I can finally see the new workflows kicking in.
Thanks for your help.

Resources