Click here to Skip to main content
14,975,931 members
Articles / DevOps / Load Testing
Posted 3 Nov 2016

Tagged as


1 bookmarked

Load Testing Error: There is already an active timer with the name '' passed to BeginTimer

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
3 Nov 2016CPOL
Fix for issue with TestContext.BeginTimer("TimerName");


Without proper setup of a TestContext instance, this error can occur. For a quick overview, you need a full property for the TestContext instance, an you DO NOT need to set the value for it.


If you create a property for TestContext and set the value in the AssemblyInitialize or ClassInitialize you are assigning your property to an instance of TestContext. If you do this in a load test, then every test reuses the same instance of that test context. If you use TestContext.BeginTimer("TimerName"); that instance of the Context adds a new Timer with that name, when the next load test runs it tries to add the same timer to the same TestContext and you get the error listed.

Proper Setup

private TestContext _testContext;

public TestContext TestContext
    get { return _testContext; }
    set { _testContext = value; }

With this setup, the TestContext property will be set from the TestExecutioner and each load test will get its own TestContext.

Bad Setup

private static TestContext _testContext;

public static void ClassInitialize(TestContext testContext)
    _testContext = testContext;

Usage of Timer


Points of Interest

Timers will show up in the test results under Scenario > Test Case Name > Transactions > Timer Name.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer
United States United States
I am currently an Automation Developer working on Coded UI Frameworks using Selenium, Load Testing Frameworks and Dynamic Data Frameworks for the prior mentioned testing systems. I maintain all of the software and hardware for our build, release and test systems, mostly using TFS, powershell and Hyper-V as well as building and maintaining Automated test systems.

SQL, Software Development, Microsoft SQL Server, Agile Methodologies
C#, JavaScript, HTML, C++, Markdown, XAML, XML
Quality Testing, Coded UI Testing, Selenium Testing, Load Testing
ALM, Team Foundation Server/VSO, Build Administration
Databases SQL/Oracle, Software and Hardware Installation/Maintenance
Troubleshooting, Project Management,
Solid State Electronics, Pulse Width Modulation, Metal Casting, Carbon Fiber Casting, Powder Coating.

Comments and Discussions

-- There are no messages in this forum --