Содержимое моего test.runsettings:
Код: Выделить всё
Как видите, файл содержит только один параметр, называемый colegio (школа) >
Это содержимое TestBase.cs:
Код: Выделить всё
using Microsoft.VisualStudio.TestTools.UnitTesting;
using InfraestructureSelenium.Helper;
using System.Collections.Generic;
using InfraestructureSelenium.Configuration.Enumerados;
namespace TestSelenium
{
[DeploymentItem("chromedriver.exe")]
[DeploymentItem("IEDriverServer.exe")]
[DeploymentItem("phantomjs.exe")]
[DeploymentItem("geckodriver.exe")]
[TestClass]
public class TestBase
{
protected TestBase()
{ }
public TestBase(int id = (int)ColegioEnum.ColegioDemoMovilidad2_Supervisor)
{
DiccionarioCompartido = new Dictionary();
SeleniumHelper = new HelperSelenium(id, WebDriverSelector.ObtenerWebDriver());
}
public TestBase(HelperSelenium seleniumHelper, Dictionary diccionarioCompartido = null)
{
SeleniumHelper = seleniumHelper;
}
public HelperSelenium SeleniumHelper { get; set; }
public static Dictionary DiccionarioCompartido { get; set; }
public void CloseBrowser()
{
SeleniumHelper.Quit();
}
#region Configuración Test
[TestInitialize]
public void InitializeTest()
{
}
[TestCleanup]
public void TestCleanupTest()
{
SeleniumHelper.Quit();
}
#endregion
}
}
Как видите, public TestBase(int id = (int)ColegioEnum.ColegioDemoMovilidad2_Supervisor) получает аргумент, соответствующий среде colegio, которую я хочу протестировать. Если в качестве аргумента не передается colegio, по умолчанию будет ColegioEnum.ColegioDemoMovilidad2_Supervisor
Однако, когда я пытаюсь создать экземпляр TestContextв TestClass, например:
Код: Выделить всё
[TestClass]
public class GenerarBoletinDeClase : TestBase
{
public TestContext TestContext { get; set; }
private static TestContext _testContext;
[TestInitialize]
public static void SetupTests(TestContext testContext)
{
_testContext = testContext;
}
public GenerarBoletinDeClase() : base((int)TestContext.Properties["colegio"]) { }
Любая помощь приветствуется, поскольку я уделил этой проблеме много времени и не смог продвинуться дальше.
Подробнее здесь: https://stackoverflow.com/questions/513 ... properties
Мобильная версия