Search code examples
c#seleniumautomated-testsperformance-testingneoload

Performance Testing: Flag when a UI/API test's runtime increases by x% (Selenium C#)


Our team currently use Selenium and C# (and NUnit) to run UI Automated tests. All tests have been manually programmed, meaning no recorders have been used.

Issue: We now have a request that these tests track their own performance (and past performance) and raise a warning when its runtime increases by x% (5% or 10%, etc).

Question: What would be the best way to accomplish this? Should we create to tool to analyze performance (performance history) of these UI and API tests from scratch or are there other tools out there we can leverage?

Blogs or stackExchange questions discussing load/performance testing usually reference three main tools for C# (NeoLoad, SilkPerformer, LoadRunnerProfessional). However, I'm not sure that what I'm being asked to do is considered performance testing (load testing) in the purest sense and therefore, not sure whether the tools mentioned above will help achieve the overall goal. They also usually separate performance/load testing from UI/API testing.

Summary: looking for advice on what direction to take and/or what to read up on for this type of testing.


Solution

  • IMHO there are too many wrong things on too many levels with this request.

    these tests track their own performance (and past performance) and raise a warning when its runtime increases by x% (5% or 10%, etc).

    Performance metrics of functional UI/API test proves what, exactly!?

    However, in case this still have to be implemented, I would suggest a simple approach - use StopWatch in before/after each C# Selenium test and store this in a central DB, which you can later query and flag in case of increase.

    // generate test case id for later use
    // create and start the instance of Stopwatch in your [SetUp] method
    Stopwatch stopwatch = Stopwatch.StartNew(); 
    // your test code here
    // in your [TearDown] method
    stopwatch.Stop();
    // store this in the DB alongside TestCaseId
    Console.WriteLine(stopwatch.ElapsedMilliseconds);