Serenity properties - cucumber-jvm

How do I use serenity properties for running cucumber jvm?
E.g:
serenity.use.unique.browser=true
serenity.requirement.types=Epics,Features
serenity.take.screenshots=FOR_FAILURES
serenity.sourceDirectory=./target/site/serenity

On Github:
https://github.com/serenity-bdd/serenity-cucumber
An example of using cucumber with serenity can be found here:
https://github.com/serenity-bdd/serenity-articles/tree/master/introduction-to-serenity-with-cucumber/src/samples/etsy-tester
Which points to the example code from the article found at:
http://thucydides.info/docs/articles/an-introduction-to-serenity-bdd-with-cucumber.html

Related

Karate UI standalone - can there be screenshots attached to reports on failure?

I am evaluating Karate UI and really like it. I use it as standalone jar (as the team do not want to support Java project but is fine with JS) and am wondering how can I attach screenshots of the web app generated right when a step fails?
I have seen this question - Attaching screenshots to json report and hope it would be possible to doing something with the standalone version as well.
If you look at the section on "hooks": https://github.com/intuit/karate#hooks
You should be able to use an afterScenario hook like this:
* configure afterScenario = function(){ if (karate.info.errorMessage) driver.screenshot() }
Works with with 0.9.5.RC4. With latest official release 0.9.4 it does not.
Edit2 - works globally with the following line in karate-config.js
karate.configure('afterScenario', read('afterScenarioScreenshot.js'))
Where afterScenarioScreenshot.js contains the JS function from above

Specflow V 3 Selenium BDD Error while running test

I am getting error below while running the test,
Message: OneTimeSetUp: System.TypeLoadException : Could not load type 'TechTalk.SpecFlow.Infrastructure.RuntimePluginAttribute' from assembly 'TechTalk.SpecFlow, Version=3.1.0.0, Culture=neutral, PublicKeyToken=0778194805d6db41'.
I am Using:
Specflow v3.1.62
Baseclass.contrib.specflow.selenium.nunit v1.3.1
VSTS 2017
The last time I checked Baseclass.contrib.specflow.selenium.nunit does only support SpecFlow 1.9.
We changed a lot in the plugin infrastructure in the meantime and so it doesn't work anymore.
You have to use something else.
One option would be an example we created some time ago which uses multiple SpecFlow+Runner features to get the same functionality as Contrib.SpecFlow.Selenium.NUnit.
You can find it here: https://github.com/techtalk/SpecFlow.Plus.Examples/tree/master/SeleniumWebTest
We also wrote an blog article about this: https://specflow.org/2018/single-test-targeting-multiple-browsers/
Full disclosure: I am one of the developers/maintainers of SpecFlow and SpecFlow+.

How to run single Jasmine test in IntelliJ IDEA

Is it possible to run single Jasmine test it or suite describe in IntelliJ from popup menu as it possible with JUnit or TestNG fremeworks?
Now I can only execute tests by running karma.conf.js that will grab all specs and run them which is not exactly what I want.
Updates
This is known issue please upvote it.
You don't need Intellij's help if you are trying to run a single unit test or a single test suite while using Jasmine. You can do that with their feature of fit() and fdescribe(). Here, prepending it(...) and describe(...) with f says those are focused tests/test suites.
Quoting the documentation (Jasmine 2.1 and above),
Focusing specs will make it so that they are the only specs that run.
Any spec declared with fit is focused.
You can focus on a describe with fdescribe
You could follow this issue in YouTrack - https://youtrack.jetbrains.com/issue/WEB-13173.
We have supported --grep[1] option for jasmine in karma already.
But there are some open discussions about problems in large projects[2]
[1] - https://github.com/karma-runner/karma-jasmine/pull/56
[2] - https://github.com/karma-runner/karma/issues/1235
Thanks!
With WebStorm 2017.1 it's possible to use RunConfiguration producer to run a single Karma test: https://github.com/develar/ij-rc-producer

#Ignore tag on SpecFlow 2.0.0 results in build error

I've recently upgraded from SpecFlow 1.9.0 to 2.0.0 and NUnit 2.6.4 to 3.2.1.
The SpecFlow feature file snippet below used to work before, however it's failing with this error now: 'NUnit.Framework.IgnoreAttribute' does not contain a constructor that takes 0 arguments
#Register #Ignore
Feature: Registration page
This is the auto-generated SpecFlow feature class snippet that's failing:
[NUnit.Framework.IgnoreAttribute()]
How can #Ignore tags be used in SpecFlow 2.0.0 and NUnit 3.x?
The use of the tag has changed in the most recent version. Now you have to give it a reason ...
#Register #Ignore("reason")
Feature: Registration page
You have to regenerate the code-behind files of the feature files.
Then the IgnoreAttribute is generated with the correct parameters.

How to configure IntelliJ for running test with JUnit 4?

Should be simple but I couldn't figure it out.
When running my unit test inside IntelliJ, I could not find a way to tell IntelliJ-9.0 that it should use JUnit4 instead of JUnit3.
When a test fails, IntelliJ console displays:
MyTests.testConstraints(MyTests.groovy:20) at
...
com.intellij.junit3.JUnit3IdeaTestRunner.doRun(JUnit3IdeaTestRunner.java:108)
at
com.intellij.junit3.JUnit3IdeaTestRunner.startRunnerWithArgs(JUnit3IdeaTestRunner.java:42)
...
Do you know how to replace JUnit3 by JUnit4 ?
I found it!
Go to Run/Debug Configurations
Add new configuration and choose a JUnit
In the configuration tab, add "-junit4" to the Test run parameters input field
And that's done !
You can annotate your test class with an annotation to indicate junit the runner it will use
#RunWith(JUnit4.class) MyTestClass {}
I tried to put:
#RunWith(JUnit4.class)
at the beginning of a test.
IntelliJ complained about this, but asked to 'load' JUnit4.class.
So I deleted #RunWith(JUnit4.class).
But the 'loading' seems to have fixed the problem - #Ignore is now respected!
Put the JUnit 4 JAR in your CLASSPATH and see if IntelliJ picks it up.
The JUnit plug-in appears to run either version 3 or 4.
I'll bet that it has to do with the way you're writing your JUnit tests. Post one to confirm. If you use the JUnit 4 style, I'll bet IntelliJ would run it properly.
'com.intellij.junit3' package belongs to IDEA binaries, not to junit3 or junit4. So, the question itself seems to be incorrect in essence - there is no difference in what package name is used by IDEA codebase internally if it correctly executes the tests.
It sounds like the real problem may be that you are trying to use junit 4 with a grails version less than 1.3. Grails 1.2.x and lower only support Junit 3 tests. Grails 1.3 will finally have junit 4 support. This was discussed on stackoverflow link text
I had the same problem with a java app inside 10.5, and it turned out to be my Project language level set to 5.0 as opposed to 8.0.
To change this go to File->Project Structure->Project->Project language level
And change this to the required level. Not sure at which level you can use JUnit4, but setting this to 5.0 will make it use JUnit3. Setting it to 8.0 makes it use JUnit4