To effectively unit test assemblies that have Loupe integrated you'll want to set up a special Assembly Initialize class to handle configuring, starting, and stopping the Loupe Agent. You can use the sample below and modify the product name to fit your scenario.
| MSTest Assembly Initialize Class Example |
Copy Code
|
|---|---|
using Gibraltar.Agent; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace UnitTestSample { /// /// Our initialization class - used at the start and end of all unit tests /// [TestClass] //you have to label the class with this or it is never scanned for methods public class AssemblyInitialize { /// /// Our one-time initialization method called at the very start of running unit tests in this assembly /// /// [AssemblyInitialize] public static void Initialize(TestContext context) { Log.Initializing += OnLogInitializing; Log.StartSession("Starting unit tests"); } private static void OnLogInitializing(object sender, LogInitializingEventArgs e) { e.Configuration.Publisher.ProductName = "Your Product"; e.Configuration.Publisher.ApplicationName = "Unit Tests"; e.Configuration.Publisher.ApplicationType = ApplicationType.Console; } /// /// Our one-time cleanup method called at the very end of running unit tests in this assembly /// [AssemblyCleanup] public static void Cleanup() { Log.EndSession("Unit tests ending"); } } } |
|