NUNIT3首先运行TestCaseSource,然后运行SetUp或SetUpFixture

时间:2017-11-15 21:08:13

标签: c# selenium selenium-webdriver nunit nunit-3.0

我不明白为什么数据条目读取(TestCaseSource)被执行(SetUp)或(SetUpFixture),在读取数据之前我需要传递一些参数,例如我将读取的excel路径和工作表

代码:

  [SetUpFixture]
public class before
{
    ManageProperti config = new ManageProperti();

    public void beforeTestFixture()
    {
        config.updateValueAppConfig("excelPath", "Alexia/Tests/Data/Login/Login.xlsx");
        config.updateValueAppConfig("hoja", "Hoja1");
    }
}

[TestFixture]
public class LoginOK : TestCase
{

    [Test]
    [TestCaseSource(typeof(ReadExcelCases), "BudgetData")]
    public void LoginOk(String username, String password)
    {
        try
        {............

不喜欢

   [TestFixture]
public class LoginOK : TestCase
{
    ManageProperti config = new ManageProperti();

    [SetUp]
    public void before()
    {
        config.updateValueAppConfig("excelPath", "Alexia/Tests/Data/Login/Login.xlsx");
        config.updateValueAppConfig("hoja", "Hoja1");
    }

    [Test]
    [TestCaseSource(typeof(ReadExcelCases), "BudgetData")]
    public void LoginOk(String username, String password)
    {
        try
        {.............

我正在阅读一个excel文件,其想法是每个测试用例都来自一个文件

谢谢!

0 个答案:

没有答案
相关问题