Specflow V 3 Selenium BDD Error while running test - selenium

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+.

Related

Configuring UnetStack in Intellij IDEA

I'm trying to use IntelliJ IDEA for my UnetStack Project.
I'm following this blog
https://blog.unetstack.net/using-idea-with-unetstack
I get this error when done following this:
Error: Could not find or load main class org.codehaus.groovy.tools.GroovyStarter
I had the same issue.
This happened to you because you ran your simulation as a groovy script and not as the configured application. Run it as application and groovyStarter will not even be used.

How to show test coverage reports for successful TFS builds

Is it possible and if so, how to have TFS display jasmine test results? I am successfully creating jasmine test reports using the plato npm package on the server during a build although I'm yet to link the report to the TFS build success page in TFS. Can someone please advise how this is possible?
Many thanks!!
Update
Initial comments refer to looking at the following link although I think this is a general link in TFS as opposed to a link relative to the "current" build.
https://www.visualstudio.com/en-us/docs/integrate/extensions/get-started/node
I have a build definition that cleans, compiles and runs jasmine tests and using plato (npm install plato) creates a html report on the server. I want developers looking at the build to be able to open the report for the build that they're looking at. Please confirm is the suggested extension link is still applicable because I've tried it just now without success.
Please advise.
Update
I've successfully included NUnit tests to be executed in our build, shown in the screen shot. I want to have a similar feature for Jasmine. The second screen shot shows the report page the Plato package produces for Jasmine tests. I would like this available within the TFS results page.
Screenshot #1 - NUnit test results (as seen in TFS)
Screenshot #2 - Plato produced jasmine results report
This reported is generated on the server in a build definition step.
You can add a custom section in build result through extension, with this way, you can add the link in that custom section.
There is the sample about build result extension:
vsts-extension-samples
More information about how to build extension, you can refer to this article (apply to on premise TFS)
Create your first extension for Visual Studio Team Services
You can use tampermonkey to inject a link into TFS. The following will work. (It's horrible but I haven't achieved the same result with any "proper" approach).
Example script
(function() {
'use strict';
setTimeout(function() {
$(".pivot-view.pivot-tabs").append("<li><a href='plato-report.html' target='_blank'>Jasmine tests</a></li>");
}, 3000);
})();
https://tampermonkey.net (for chrome)
https://addons.mozilla.org/en-gb/firefox/addon/greasemonkey/ (for firefox)

#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.

Undefined step definitions in IntelliJ

I'm trying to follow this article to match Cucumber specs with step definitions in IntelliJ.
When I press Alt+Enter, I see Inspection 'Undefined Step' options. However, I should see the intention action Create Step Definition.
I thought I had the Cucumber IntelliJ plugin installed, so that shouldn't be a problem. Any help is greatly appreciated.
Turns out I had the Gherkin plugin but not the Cucumber for Java plugin.
I wasted around an hour to solve this. My issue was, Idea was able to navigate from feature to step file. But when I wanted to execute one cucumber test from feature file (Right click and Run Scenario), it was giving error as undefined steps.
Solution: In the Edit Configuration -> provide the Glue for the cucumber which should be absolute path till steps folder. Please see below screen shot
This fixed my problem of running feature file from Idea.
Hope this helps others.
Most probably you need to install the cucumber for java plugin, if already installed then you need to enable from File>>Settings>>pugins.
I had to uncheck the "Create separate module per source set" checkbox under the "Build, Execution, Deployment" -> "Build Tools" -> "Gradle" settings, and then rebuild the project.
"Undefined" step error message would appear if you import a new BDD project.
This error could appear due to two reasons.
If you have not installed the "Cucumber for Java" plugin.
If you import any BDD projects then it will not detect step definition file.
Solution:
1. If the plugin is not found then you need to install from the below location.
File->Settings->Plugins->MarketPlace->Cucumber for Java
2. After Importing the project disable the plugin and enable once again in the Installed section under Installed.
For me there was a collision between Sidesteps plugin and Cucumber plugin in Intellij and as a result *.feature file extension was taken over by the Sidesteps plugin and was expecting Sidesteps step definitions ignoring Cucumber step definitions. No clue what Sidesteps actually is. So went to IntelliJ settings and reassigned the *.feature extension to Cucumber Scenario type and then everything worked fine and Cucumber steps are recognized by Intellij now.
I had the same issue where all of a sudden my feature to step definition glue was missing. All i did was goto Run->Edit Configurations->and removed the cucumber java
configuration and restarted IntelliJ. it worked fine.
I found that even with the Cucumber for Java plugin installed it was still generating only one step. I eventually uninstalled the Cucumber for Java plugin and reinstalled it and all step definitions were generated.
The issue was fixed after updating the Intelij to the latest version and after updating the cucumber and gherkin intelij plugins
Me not help not one of suggestions above.
But i find if you start one test from runner the problem goes on (it is worked if you have runner for some tests( Runner is class that have line #CucumberOptions(
features = "src/test/resources/stability_*****_features/",
glue = "steps"
)
And may be the next line in config helped you^
in configurations i put line: --plugin org.jetbrains.plugins.cucumber.java.run.CucumberJvm4SMFormatter
in Programm arguments line - it help me
If still not working, you can add runner class
add -> runner package -> Main Runner class
-test
-runner - Create this package
-stepPackage
-resources
-features
#CucumberOptions(features = {"classpath:features"}, glue = {"stepDefinition"},
monochrome = false,dryRun = false)
public class MainRunner extends AbstractTestNGCucumberTests {
}
That is it. Just run this class first. Right mouse click and Run'MainRunner'
Then it will work if you just go back and run Scenarios as well
I had the same issue and was resolved by going to Run> Edit configuration> Before Launch then click on the add option "+" and add Build Project option.
enter image description here

Weblogic 12c HibernateValidator ClassLoading issue

Validation framework which has been rolled up as part of the JEE6 spec (WL12). Both the WL10 and WL12 versions of our application were deployed with the following open source libraries:
JSR-303 / validation-api.jar (version 1.0)
Hibernate Validator (version 4.2.0)
However, the libraries are also bundled with WL 12 (modules directory). Note that the Hibernate Validator version is slightly different.
modules.javax.validation_1.0.0.jar
hibernate.validator_4.1.0.jar
With our WL12 run we are getting below exception:
javax.validation.ValidationException: Unable to get available provider
Attempted Solutions
Our next attempt was to use the WebLogic FilteringClassLoader to prefer the libraries from our application (APP-INF/lib directory) by specifying them in the weblogic-application.xml file (i.e. choose our versions over WebLogic’s). We were already doing this for several other open source libraries in WL10:
<prefer-application-packages>
<package-name>com.google.common.*</package-name>
<package-name>org.apache.commons.lang.*</package-name>
<package-name>org.apache.commons.logging.*</package-name>
<package-name>org.apache.commons.beanutils.*</package-name>
<package-name>org.apache.commons.collections.*</package-name>
<package-name>antlr.*</package-name>
<package-name>javax.validation.*</package-name>
<package-name>org.hibernate.validator.*</package-name>
</prefer-application-packages>
After making that change, our application experienced the following run-time error trying to process any request that makes use of the validation framework:
javax.validation.ValidationException: Unable to get available provider resolvers.
at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:259)
at web20.hibernate.validation.ValidatorFactoryConfigurator.getValidatorFactory(ValidatorFactoryConfigurator.java:39)
at web20.hibernate.validation.ValidationHandlerImpl.handleHibernateValidations(ValidationHandlerImpl.java:180)
at web20.hibernate.validation.ValidationHandlerImpl.performValidation(ValidationHandlerImpl.java:255)
at web20.hibernate.validation.ValidationHandlerImpl.validateAndFormatMessages(ValidationHandlerImpl.java:302)
at web20.hibernate.validation.ValidationHandlerImpl.validateUsingHibernateGroups(ValidationHandlerImpl.java:113)
at service.serviceapp.performValidations(serviceapp.java:392)
at service.serviceapp.performValidations(serviceapp.java:379)
at service.TransactionalServiceImpl.search(TransactionalServiceImpl.java:300)
Given that Bean Validation is part of the EE standard, I assume there is some code Bean Validation integration code which causes the problem. I see two potential solutions:
Patch the WL instance and upgrade to the Validator version you want to use
Try writing your own ValidationProvider. Internally it could just delegate to the Hibernate Validator classes. If you then add a validation.xml to your application, specifying your custom provider, WL should bootstrap this one. TBH, I don't know whether this will work. There are many unknowns and I don't know enough about the integration of WL and Bean Validation.
Personally, I think I would just try to upgrade the Validator version used in WL.