Add a file to the solution called config1.RunSettings
. Add Parameter(s) to the file to change the configuration.
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<TestRunParameters>
<Parameter name="config" value="config1" />
</TestRunParameters>
</RunSettings>
AssemblyInit
will run once before the tests start. Use the to make any configuration changes.
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UnitTestProject1
{
[TestClass]
public class SetupAssemblyInitializer
{
[AssemblyInitialize]
public static void AssemblyInit(TestContext context)
{
// Initalization code goes here
// https://stackoverflow.com/questions/2382552/is-it-possible-to-execute-code-once-before-all-tests-run
// set load configuration from runsettings here
context.Properties["config"];
}
}
}