Integration Testing and Load Testing : using the same scenarii (JVM) - cucumber

At the moment, I'm using two different frameworks for REST APIs integration testing, and load/stress testing. Respectively : geb (or cucumber) and gatling. But most of the time, I'm re-writing some pieces of code in load / performance scenarii that I've been writing for integration testing.
So the question is : is there a framework (running on the JVM) or simply a way, to write integration tests (for a strict REST API use case), preferably programmatically, then assemble load testing scenarios using these integration tests.
I've read cucumber maybe could do that, but I'm lacking a proper example.
The requirements :
write integration tests programmatically
for any integration test, have the ability to "extract" values (the same way gatling can extract json paths for instance)
assemble the integration tests in a load test scenario
If anyone has some experience to share, I'd be happy to read any blog article, GitHub repository, or whatever source dealing with such an approach.
Thanks in advance for your help.

It sounds like you want to extract a library that you use both for your integration tests as well as your load test.
Both tools you are referring to are able to use external jar.
Suppose that you use Maven or Gradle as build tool, create a new module that you refer to from both your integration tests and your load tests. Place all interaction logic in this new module. This should allow you to reuse the code you need.

Related

Cucumber Framework Migration - Existing Rest Assured to Karate Framework

I am working as automation tester for banking domain account. I have a query and need your help.
Current Approach :
1.The framework which we are using for API-Services testing is Java based - Serenity -Cucumber framework using Rest Assured.
2.All the script development/script maintenance activities related to this framework is taken care by the automation testers in our team.
3.Few weeks before , we got to know about Karate framework and completed the PoC( Proof of concept).
4.All went well and we are in the plan to migrate our existing Rest assured java code Karate framework.
The reason for migration - Karate framework Api services testing can be able to do by Manual testers as well.So we are in the plan for migration.
Query
We have almost 80 web services already developed in Rest assured and running successfully.
Also for migration, all the services are inter-dependent. So we have to use both Res-assured and Karate framework code together ,unless it's fully migrated.
Can't able to migrate all the services immediately ,it's a time taken effort.
Is it possible to run karate framework and Rest Assured Java code in the same scenario.
Scnario given in Karate Feature file:
Given urlCustomerservices
When method get
Then status 200
def getCustIDfromUserservices=newcallJavaFunction().getcustid("user","password")
print getCustIDfromUserservices
This "getcustid" have the Rest assured java code for "Post" call service to get the customer number.
When I am running this in code karate framework , getting this error -
"io.restassured.internal.RequestSpecificationIMpl.invokeMethod(java/lang/String;Ljava/lang/object;)Ljava/lang/object;
Could any help in this. Whether can we run both karate and Rest assured code together in same scenario in karate framework . If yes, why am getting this error, when am trying to get the response in Rest assured.
First I'll say that this is not something we claim to support :) So you are on your own.
That said, it sounds like a simple library conflict. My guess is your existing Maven pom.xml has a lot of libraries floating around. You will need to do some investigation and find out what maven exclusions you need to do or which libraries need explicit versions specified. If you are lucky, switching from karate-apache to karate-jersey may do the trick.
Also I strongly recommend creating a Karate quickstart, then adding the extra stuff one by one in "hello world" mode and see what causes the problem. Use the mvn dependency:tree command and see the differences between a Karate project and yours. If you know how to use Maven profiles, that may be one way to go. All the best !
Worst case, fall back to 2 maven modules and run 2 test-suites, it is fine and not the end of the world. You can gradually migrate.
EDIT - also see https://stackoverflow.com/a/65628686/143475

Is there any SAST tool for Workfusion code?

Currently I'm involved in a project for implementing security code reviews for Workfusion bots. Workfusion can handle a mix of Java and Groovy code embedded in XML files or standalone code.
My team is trying to assess if it's possible to use any free/opensource Static Application Security Tool for it. I'm currently exploring the posiblity of creating a plugin for Spotbugs.
I was able to run reviews successfully with Java code + Maven with Spotbugs and FindSecBugs plugins, but I haven't figured out how to extend Spotbugs in order to parse the XML files, extract the embedded Groovy scripts and analyze them.
Do you know any static application security tool for Workfusion or could suggest any approach to extend any other SAST tool?
The main requirement for Find Security Bugs to work is the ability to compile the code.
If you have access to the class files, FindSecurityBugs should work. If the code is evaluate at runtime, you'll need to compile the snippet which is not an easy task if the script have access to a special context with initialized objects.

Executing cucumber (gherkin scripts) with SOAP UI ?

I'm trying to find possibilities for the BDD approach of testing my web services with SOAP UI & Cucumber. Is there any way to achieve this ? Please advise
Thanks
Exactly, both SOAPUI and Cucumber are different test runners. You have to choose between both. Except that SOAPUI provides you http-clients for calling services and Cucumber can contain any tests that use different libraries/clients to do different type of testing.
Presuming that you are thinking to use SoapUI just as http-client for services testing, its better to use Jersey client and use Cucumber/JBehave as BDD runner.
I Do Agree with #I Am's answer. Using Jersey or other httpclient do the needful. In case of jersy with BDD you can use QAF with Web service plugin. You can use cucumber gherkin or QAF BDD or pure java for test authoring. QAF bdd for web-service may look like below:
SCENARIO: My Fist webservice call
META-DATA: {"description":"Just for learning purpose"}
When user requests '${get.sample.call}'
Then response should have status 'OK'
END
Where, get.sample.call will be in properties file holding request details.

How to keep gherkin files in sync with automated tests in specflow or other BDD gherkin/cucumber frameworks

So I'm confused about the process/steps to keep automated tests in sync with gherkin/feature files in specflow. Assuming the feature files are written in gherkin and checked into git source control.
I see that there is a tool to generate stub automated tests from a gherkin file, and that flows naturally into letting a developer implement those tests.
My question is if the features and spec change, what is the workflow for refactoring or updating those tests to keep it in sync? Is it done manually by the developer, or does specflow or other BDD driven tools have something to help you manage the refactoring of the test files?
There is no tool support that will update the steps when the wanted behavior changes.
The steps that are used for automating the specifications has to be maintained manually in the same way as the steps was implemented when they where new.
Anyone capable of implementing the code used in the automation has to do it. This may be a developer, a tester or someone else with sufficient knowledge about the domain and programming.

Testing Web Site Project with NUnit

i'm new in web dev and have following questions
I have Web Site project. I have one datacontext class in App_Code folder which contains methods for working with database (dbml schema is also present there) and methods which do not directly interfere with db. I want to test both kind of methods using NUnit.
As Nunit works with classes in .dll or .exe i understood that i will need to either convert my entire project to a Web Application, or move all of the code that I would like to test (ie: the entire contents of App_Code) to a class library project and reference the class library project in the web site project.
If i choose to move methods to separate dll, the question is how do i test those methods there which are working with data base? :
Will i have to create a connection to
db in "setup" method before running
each of such methods? Is this correct that there is no need to run web appl in this case?
Or i need to run such tests during
runtime of web site when the
connection is established? In this case how to setup project and Nunit?
or some another way..
Second if a method is dependent on some setup in my .config file, for instance some network credentials or smtp setup, what is the approach to test such methods?
I will greatly appreciate any help!
The more it's concrete the better it is.
Thanks.
Generally, you should be mocking your database rather than really connecting to it for your unit tests. This means that you provide fake data access class instances that return canned results. Generally you would use a mocking framework such as Moq or Rhino to do this kind of thing for you, but lots of people also just write their own throwaway classes to serve the same purpose. Your tests shouldn't be dependent on the configuration settings of the production website.
There are many reasons for doing this, but mainly it's to separate your tests from your actual database implementation. What you're describing will produce very brittle tests that require a lot of upkeep.
Remember, unit testing is about making sure small pieces of your code work. If you need to test that a complex operation works from the top down (i.e. everything works between the steps of a user clicking something, getting data from a database, and returning it and updating a UI), then this is called integration testing. If you need to do full integration testing, it is usually recommended that you have a duplicate of your production environment - and I mean exact duplicate, same hardware, software, everything - that you run your integration tests against.

Resources