Comments (4)
Please find the required details
-
.Net Framework 4.6.1 - Class library
-
NuGet: RestSharp - 110.2.0, Abstracta.JmeterDsl - 0.3.2, MSTest.TestAdapter - 2.1.2, MSTest.TestFramework - 2.1.2
-
Adapter Class
using RestSharp;
using System;
using static Abstracta.JmeterDsl.JmeterDsl;
namespace RestApiTest
{
public enum Response
{
Success,
Failure
}
public class RestApiTestAdapter
{
private readonly RestClient restClient;
private readonly string baseUrl;
public RestApiTestAdapter(string baseUrl)
{
this.baseUrl = baseUrl;
restClient = new RestClient(baseUrl);
}
public Response ExecuteAndTestPerformance(string resource, string method, int noOfThreads, int noOfIterations, long maxTimeInSeconds)
{
string uri = baseUrl + '/' + resource;
var stats = TestPlan(
ThreadGroup(noOfThreads, noOfIterations,
HttpSampler(uri).Method(method)
)
).Run();
if(stats.Overall.SampleTimePercentile99 < (TimeSpan.FromSeconds(maxTimeInSeconds)))
{
return Response.Success;
}
return Response.Failure;
}
}
}
- Test Class
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace RestApiTest
{
[TestClass]
public class Test
{
private static RestApiTestAdapter restApiTestAdapter;
public TestContext TestContext { get; set; }
[ClassInitialize]
public static void RestApiTestInitialize(TestContext testContext)
{
restApiTestAdapter = new RestApiTestAdapter("http://localhost:56349");
}
[TestMethod]
//[DataSource("System.Data.Odbc", @"Dsn=Excel Files;dbq=.\\TestData\\RestApiPerfTestData.xlsx;defaultdir=.; driverid=790;maxbuffersize=2048;pagetimeout=5", "Sheet1$", DataAccessMethod.Sequential)]
public void TestApiPerformance()
{
string resource = "weatherforecast";
string method = "Get";
int noOfThreads = 3;
int noOfIterations = 10;
long maxTimeInSeconds = 3;
Assert.AreEqual(restApiTestAdapter.ExecuteAndTestPerformance(resource, method, noOfThreads, noOfIterations, maxTimeInSeconds), Response.Success,
$"Resource: {resource}, Method: {method}, noOfThreads: {noOfThreads}, inoOfIterations: {noOfIterations}, maxTimeInSeconds: {maxTimeInSeconds}");
}
[ClassCleanup]
public static void RestApiTestCleanup()
{
}
}
}
from jmeter-dotnet-dsl.
Using JmeterDsl with .Net Framework.. with .Net Core it is working fine
from jmeter-dotnet-dsl.
Thank you for reporting this and providing details when it works fine. Can you provide a little more details on what you are using? What version of .Net Framework? Any other details you would like to provide that you think might help us?
from jmeter-dotnet-dsl.
Thank you for the detailed info, that helped reproduce the issue and fix it.
The fix is included in 0.4.
I will close this issue. If you have further comments let me know and we can re open the issue.
from jmeter-dotnet-dsl.
Related Issues (18)
- Setting name for HttpSampler is not working HOT 2
- I need to create POST requests with different body each one HOT 5
- `Perc99` lower than `Perc95` and `Perc90` HOT 2
- Connect to WebSocket/SignalR HOT 2
- Add possibility to run HttpSampler to execute a fixed number of times. HOT 2
- Add A Support for Post Request with FormParams JMeter DSL Dotnet HOT 1
- Incorporate functionality to verify the expected response. HOT 2
- threadPause support? HOT 2
- Error when trying to execute a simple test using a CSV file and Azure Load Testing HOT 2
- Backend Listener HOT 1
- How to detect Java_Home is correct set? HOT 4
- Missing allow quoted data in DslCsvDataSet HOT 4
- Threadgroup missing Loopcount in configuration HOT 1
- Assertion missing Average option HOT 8
- Perfmon Plugin & Updation of JMeter Properties in jmeter dsl dotnet HOT 6
- Please add the ability to generate HTML reports from the execution of test plans. HOT 1
- ERROR org.apache.jmeter.util.JMeterUtils - Could not find resources for 'ru_RU' HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jmeter-dotnet-dsl.