LoadTestGoalBasedLoadProfile Class
Represents the load profile of a load test that has a goal-based load pattern.
Namespace: Microsoft.VisualStudio.TestTools.LoadTesting
Assembly: Microsoft.VisualStudio.QualityTools.LoadTestFramework (in Microsoft.VisualStudio.QualityTools.LoadTestFramework.dll)
Syntax
'Declaration
<SerializableAttribute> _
Public Class LoadTestGoalBasedLoadProfile _
Inherits LoadTestLoadProfile
'Usage
Dim instance As LoadTestGoalBasedLoadProfile
[SerializableAttribute]
public class LoadTestGoalBasedLoadProfile : LoadTestLoadProfile
[SerializableAttribute]
public ref class LoadTestGoalBasedLoadProfile : public LoadTestLoadProfile
public class LoadTestGoalBasedLoadProfile extends LoadTestLoadProfile
Examples
In the following example, a Load Test Plugin constructs a GoadBasedLoadProfile object and assigns it to the LoadTestScenario. It also assigns a value for DelayBetweenIterations to the LoadTestScenario in the Initialize() method.
using Microsoft.VisualStudio.TestTools.LoadTesting;
public class LoadTestPluginInitChangeProfile : ILoadTestPlugin
{
public void Initialize(LoadTest loadTest)
{
LoadTestGoalBasedLoadProfile goalLoadProfile = new LoadTestGoalBasedLoadProfile();
goalLoadProfile.MachineName = Environment.MachineName;
goalLoadProfile.CategoryName = "Processor";
goalLoadProfile.CounterName = "% Processor Time";
goalLoadProfile.InstanceName = "_Total";
goalLoadProfile.InitialUserCount = 5;
goalLoadProfile.MinUserCount = 1;
goalLoadProfile.MaxUserCount = 100;
goalLoadProfile.MaxUserCountIncrease = 10;
goalLoadProfile.MaxUserCountDecrease = 5;
goalLoadProfile.MinTargetValue = 20;
goalLoadProfile.MaxTargetValue = 25;
// This example assumes that there is only one scenario
loadTest.Scenarios[0].LoadProfile = goalLoadProfile;
loadTest.Scenarios[0].DelayBetweenIterations = 5;
}
}
In the following example, a Load Test Plugin modifies selected properties of a GoalBasedLoadProfile in the HeartbeatEvent handler. This approach works only if the load profile specified in the .loadtest file is a Goal Based Load Pattern.
using Microsoft.VisualStudio.TestTools.LoadTesting;
public class LoadTestPluginChangeGoal : ILoadTestPlugin
{
private LoadTest m_loadTest;
private LoadTestScenario m_scenario1;
private bool m_goalChanged;
public void Initialize(LoadTest loadTest)
{
m_loadTest = loadTest;
// This example assume there is only one scenario
m_scenario1 = loadTest.Scenarios[0];
m_loadTest.Heartbeat += new EventHandler<HeartbeatEventArgs>(m_loadTest_Heartbeat);
}
void m_loadTest_Heartbeat(object sender, HeartbeatEventArgs e)
{
if (e.ElapsedSeconds >= 60 && !m_goalChanged)
{
LoadTestGoalBasedLoadProfile goalLoadProfile =
m_scenario1.LoadProfile.Copy() as LoadTestGoalBasedLoadProfile;
goalLoadProfile.MinTargetValue = 50;
goalLoadProfile.MaxTargetValue = 60;
m_scenario1.LoadProfile = goalLoadProfile;
m_goalChanged = true;
}
}
}
Inheritance Hierarchy
System.Object
Microsoft.VisualStudio.TestTools.LoadTesting.LoadTestLoadProfile
Microsoft.VisualStudio.TestTools.LoadTesting.LoadTestGoalBasedLoadProfile
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
See Also
Reference
LoadTestGoalBasedLoadProfile Members
Microsoft.VisualStudio.TestTools.LoadTesting Namespace