Git Product home page Git Product logo

Comments (4)

nandish-1603 avatar nandish-1603 commented on June 15, 2024 1

Please find the required details

  1. .Net Framework 4.6.1 - Class library

  2. NuGet: RestSharp - 110.2.0, Abstracta.JmeterDsl - 0.3.2, MSTest.TestAdapter - 2.1.2, MSTest.TestFramework - 2.1.2

  3. 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;
    }
}

}

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

nandish-1603 avatar nandish-1603 commented on June 15, 2024

Using JmeterDsl with .Net Framework.. with .Net Core it is working fine

from jmeter-dotnet-dsl.

rabelenda avatar rabelenda commented on June 15, 2024

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.

rabelenda avatar rabelenda commented on June 15, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.