Basic Jmeter Framework for Functional testing - frameworks

Does anyone know or have implemented a basic framework in Jmeter which helps achieve re-usability and robustness.
I currently have 4 API's (upload file, get details, update file, delete file)
Now i need to test this for different formats.
I initially took the approach of putting all 4 api's in a thread group and disabling that group.
Then i called each api's using a module controller for different formats of the file.
This helped me achieve reusability but then asserting responses and extracting response using regex. extractor, became difficult and next to impossible.
Is there a way to achieve reusability in Jmeter? Module Controller works but it doesn't allow regex extractor which can inturn be used for assertion.
Instead of adding multiple assertions and regex extractors in every HTTP call, i would like to add it once and then probably reuse it.

I faced similar issues while implementing complex functional tests for a large web application. I used components mentioned below to achieve reusability:
Module Controller
Parameterized Controller
Loop Controller
IF controller
Beanshell & JMeter functions
You should not face any issue with use of Regex extractor under any controller. For conditioning you can use IF controller and Beanshell.
Parameterized controller is extremely useful if you need to use same samplers but with different datasets/values.

Related

manage state across multiple requests in wiremock

We would like to extend Wiremocks standard behavior with our own extension that allows for state to be managed across multiple request/response pairs. In particular, we need to aggregate data from a number of requests that is then returned upon invocation of a particular URL. Our question is whether this is even possible with Wiremock and how it could be achieved.
The only idea we have had so far is to introduce custom handlebars that read from/write to global state (e.g., static fields), but is there some other extension mechanism that we are missing? We are aware that this is something you would typically implement with a standard application server, however we have already heavily invested (architecturally speaking) in Wiremock and would prefer to find a compatible solution.
I should add that we are actually using Wiremock Studio rather than plain Wiremock, which may affect what kind of extensions are possible.

Create ABAP REST Class to query multiple entities

I don't have Gateway available in my landscape and I want to use the ABAP REST library to expose web services: SAP Library - REST Programming Tutorial
With a very simple example, I successfully created a class to read a single domain list of values, the GET call is quite simple:
http://mydomain/domainvalues/XFELD
And the GET implementation is in my class ZCL_REST_DOMAIN_VALUES extending from CL_REST_RESOURCE implementing IF_REST_RESOURCE~GET method.
Now I want to make it possible to read or query multiple domains. I'm not an expert in REST but I've seen two options searching around, one using the same URI as the single entity and one with special URI for queries.
http://mydomain/domainvalues?Id=XFELD,WERKS_D
http://mydomain/query/domainvalues?Id=XFELD,WERKS_D
In the backend, should I use the second approach and create a class only for this call named for instance ZCL_REST_DOMAIN_VALUES_QUERY implementing the GET method again?
Or maybe should I use POST method to send the list of IDs to fetch in the body?
SAP's own in-house guidelines recommend to shape OData and plain REST services alike, to avoid confusion and facilitate switching between the two:
http://mydomain/domainvalues?$filter=Id in ('XFELD', 'WERKS_D')
Both would be served by the same REST endpoint handler class, although of course you are free to create separate methods or delegates for the cases.
Remember to sanitize (= whitelist/blacklist/escape) the query parameters before handing them over to some lower level to prevent SQL injection attacks, as #SandraRossi correctly pointed out below.

Switching to Gatling for Load Testing

I'd like to use Gatling for REST performance and scalability web service testing. I'm currently using JMeter for this as I wasn't aware of gatling when I started this project. Gatling would integrate better and would be better for the project a number of reasons.
I'd like to ask one main question:
Obviously, there's a lot of overhead in configuring Gatling with the correct web service information. I've already done this in JMeter and I'm not keen to do it again. For one of the sub-projects, we have a WADL but we have no such thing for the other. Is it possible, out of the box, to import:
a. JMeter test plans and
b. WADL documents
into Gatling?
I've looked through the docs but unfortunately I can't find anything that references these.
No, Gatling has neither.
Building a jmx converter is something we might investigate in 2013, as you're not the first one to ask for it. At this point, I'm a bit skeptical, as the logic and the configuration of the 2 JMeter and Gatling are quite different, so the features and the way to use them don't map 1:1.
The easiest way to work with REST APIs is to use the recorder, so you'd dump request bodies as template and then inject data into them. See http://gatling.io/docs/2.1.6/http/http_request.html#request-body
If you work with JSON, you can use our JsonPath (or standard regex) checks in order to make assertions on the response body, or even capture data. See http://gatling.io/docs/2.1.6/http/http_check.html#defining-the-check-type
Using HttpSampler with Raw Post body And last 2.8 version is the right way to test Webservices.
Is it the way you are doing it ?
Upcoming 2.9 has new performance improvements related to memory and cpu consumed by Post Processors.
Regarding a, I don't think so.

How to go about implementing Specflow with WPF app using MVVM

We have an app which is developed in wpf + DevExpress using MVVM pattern. We need to implement Specflow with MStest on viewmodel level.
Have anyone tried this? Any pointers? Is codedUI any good at viewmodel level?
I had two thoughts when I read that question.
First - think if you really need to automate everything through the UI. With an architecture like MVVM you have a great opportunity to hit the application beneath the UI and still get a lot out your test automation. For example write your step definitions against the ViewModels.
Testing against the UI easily run the risk of creating brittle tests. The UI is the part of most application that changes very frequently. Tests hitting the UI need to cope with this somehow (more on this later).
Secondly, for the things that you need to automate against the UI, consider using White which is a nice object oriented abstraction above the UI Automation Library. I've used it extensively and like it.
With any automation be sure to create an abstraction over the actual automation, with the driver pattern for example. A simple way to do this is to create a screen/page object that have properties and methods to interact with the screen/page in question. Your step definitions then uses these wrapper objects.
Keep your step definitions thin and your wrapper objects fat. A bit like a controller in the MVC-pattern. More on this here
I hope this was helpful
Well I haven't tried it but I can't see anything wrong with it. By using specflow you create methods to do one thing say "The user presses the about button" and your code would be something like this
[Given(#"The user presses the about button")]
public void TheUserPressesTheAboutButton()
{
this.UIMap.PressAboutButton();
}
You may have to fiddle around to create all the methods but it's not a big deal. There's a simple guide here. Something that could be a glitch is the naming and identification of the controls so that CUIT builder would be able to find them.
Yes. It works pretty good. The biggest challenge is really defining your sentence structure and Given/When/Then statements so they are consistent and re-usable. Otherwise you end up with Tags and 5-10 givens for a single method. Not really maintainable.
We used Specflow for unit testing MVVM as well as other business components. The Given statements would basically setup the mock data, then execute the test:
Given I have created a database context
And it contains the following Books
|ISBN | Author | Title |
...
I also used specflow for Functional Testing (end to end) for automated testing via TFS. A database and server are deployed (with real or test data), then the functional test suite is executed against that server/database (creating data, modifying data, etc).

ASP.Net Integrated Pipeline and HTTPResponseBase.Headers

Ok...
I'm writing a ASP.Net MVC 2 application, and one of the requirements is that I log the headers on the requests we receive, and also on the responses we send...
My approach to do this has been to create a controller that overrides OnActionExecuting and OnActionExecuted, and then create our actual "live" controllers by inheriting from this rather than from the usual base class. This way, I basically get the logging functionality for free.
While this approach works fine for handling the requests, responses seem to be another matter. I am getting an error telling me that the Headers property of the HTTPResponseBase class requires IIS to be using the Integrated Pipeline. I therefore have two questions.
Question 1.
Can anyone suggest a means to get the headers through a means other than HTTPResponseBase.Headers? I have considered for example simply parsing the entire resposne and getting them that way myself, but I was hoping someone might have a better way...
Question 2.
What is this Integrated Pipeline? What does it do? How do I enable it?
Cheers in anticipation...
Martin.
In response to Question 2:
Integrated Pipeline is a new feature in IIS 7 and higher, you can change the application pool in IIS7 to use this new pipeline.