Automated UI Testing with Visual Studio 2012: Listing 2.

Leveraging Test/Class Initialize/Cleanup methods for starting and stopping the application under testing.

[CodedUITest]
public class CalculatorTests
{
  public CalculatorUIMap CalculatorUIMap { get; set; }

  [TestInitialize]
  public void TestInitialize()
  {
    CalculatorUIMap = new CalculatorUIMap();
    CalculatorUIMap.LaunchCalculator();
  }

  [TestCleanup]
  public void TestCleanup()
  {
    CalculatorUIMap.ShutdownCalculator();
  }

  [TestMethod]
  public void LaunchAndShutdownCalculator()
  {
    CalculatorUIMap.TestCalculator();
    CalculatorUIMap.AssertTotal();
  }
}

About the Author

Mark Michaelis (http://IntelliTect.com/Mark) is the founder of IntelliTect and serves as the Chief Technical Architect and Trainer. Since 1996, he has been a Microsoft MVP for C#, Visual Studio Team System, and the Windows SDK and in 2007 he was recognized as a Microsoft Regional Director. He also serves on several Microsoft software design review teams, including C#, the Connected Systems Division, and VSTS. Mark speaks at developer conferences and has written numerous articles and books - Essential C# 5.0 is his most recent. Mark holds a Bachelor of Arts in Philosophy from the University of Illinois and a Masters in Computer Science from the Illinois Institute of Technology. When not bonding with his computer, Mark is busy with his family or training for another triathlon (having completed the Ironman in 2008). Mark lives in Spokane, Washington, with his wife Elisabeth and three children, Benjamin, Hanna and Abigail.

comments powered by Disqus

Featured

  • VS Code 1.130 Expands Agent Host and Review Tools

    Microsoft's latest weekly VS Code release advances shared agent sessions, multi-file change review, chat visibility and terminal navigation

  • Microsoft Agent Framework Makeover: Claws, Loops and Harnesses

    Microsoft's newly released Agent Framework Harness packages the loops, planning, memory, context management and safety controls that developers previously had to assemble around AI models themselves.

  • Visual Studio 2026 Gives Copilot Built-In Skills -- and Makes Them Prove Their Worth

    Microsoft is moving Agent Skills beyond bring-your-own instructions by shipping expert-authored workflows with the IDE, while keeping them off by default until testing shows their benefits justify the additional token use.

  • Copilot AI Billing Shock Met with Meters, Caps and Token-Saving Tools

    GitHub is layering spending limits, expanded credit allowances and increasingly granular usage reporting onto Copilot, while Microsoft is reworking Visual Studio and VS Code to expose -- and reduce -- the cost of agentic development.

Subscribe on YouTube