Skip to content

Performance measures

Jakub Raczek edited this page Apr 25, 2019 · 10 revisions

Our framework allows you to measure time any of test step and displays average and 90 Percentile action time. These action time can be displayed as additional tests. That functionality together with JMeter and Teamcity can be used for measuring performance of a web application on the client and server side. More details can be found here.

Example of performance test:

namespace Ocaramba.Tests.NUnit.Tests
{
    using Automation.Tests.PageObjects.PageObjects.TheInternet;
    using global::NUnit.Framework;

    /// <summary>
    /// Tests to test framework
    /// </summary>
    [TestFixture]
    [Parallelizable(ParallelScope.Fixtures)]
    public class PerformanceTestsNUnit : ProjectTestBase
    {
        [Test]
        [Repeat(3)]
        public void HerokuappPerfTests()
        {
            this.DriverContext.PerformanceMeasures.StartMeasure();
            InternetPage internet = new InternetPage(this.DriverContext);
            internet.OpenHomePage();
            this.DriverContext.PerformanceMeasures.StopMeasure(TestContext.CurrentContext.Test.Name + "LoadingMainPage");
            this.DriverContext.PerformanceMeasures.StartMeasure();
            internet.GoToCheckboxesPage();
            this.DriverContext.PerformanceMeasures.StopMeasure(TestContext.CurrentContext.Test.Name + "LoadingCheckboxesPage");
        }
    }
}

Results of performance measures must be printed in ProjectTestBase class, more details here. Our framework supports only displaying performance results in TeamCity and AppVeyor. Below example of how use it for NUnit.

        /// <summary>
        /// After the class.
        /// </summary>
        [OneTimeTearDown]
        public void AfterClass()
        {
            PrintPerformanceResultsHelper.PrintAverageDurationMillisecondsInAppVeyor(this.DriverContext.PerformanceMeasures);
            PrintPerformanceResultsHelper.PrintPercentiles90DurationMillisecondsInAppVeyor(this.DriverContext.PerformanceMeasures);
            PrintPerformanceResultsHelper.PrintAverageDurationMillisecondsInTeamcity(this.DriverContext.PerformanceMeasures);
            PrintPerformanceResultsHelper.PrintPercentiles90DurationMillisecondsinTeamcity(this.DriverContext.PerformanceMeasures);
            this.DriverContext.Stop();
        }

Performance printing class API can be found here.

Clone this wiki locally