data-driven-tests

How do you get the iteration / line number from TestContext in data driven tests?

牧云@^-^@ 提交于 2019-12-03 11:07:23
I've implemented a data driven test using MsTest framework. I was wondering if there was a way to get the iteration / line number of the current test code from the TestContext object? As far as I can see, the only property relevant to DDT is DataRow that enables getting info for the current iteration from the data source, but I don't see any property that gives me what I need. Try this: int currentIteration = TestContext.DataRow.Table.Rows.IndexOf(TestContext.DataRow); private readonly PropertyInfo _rowIdProp = typeof(System.Data.DataRow).GetProperty("rowID", BindingFlags.NonPublic |

MemberData tests show up as one test instead of many

▼魔方 西西 提交于 2019-12-03 10:38:33
问题 When you use [Theory] together with [InlineData] it will create a test for each item of inline data that is provided. However, if you use [MemberData] it will just show up as one test. Is there a way to make [MemberData] tests show up as multiple tests? 回答1: I spent a lot of time trying to figure this one out in my project. This related Github discussion from @NPadrutt himself helped a lot, but it was still confusing. The tl;dr is this: [MemberInfo] will report a single group test unless the

pass test case parameters using nunit console

天涯浪子 提交于 2019-12-03 09:02:48
问题 I am developing tests using Nunit and data driven testing approach. I have test method with 2 parameters: path to xlsx file and worksheet name. It works perfect in Visual Studio when I pass parameters in TestCase attribute, for example when I want to run 3 test cases have to write something like this: [TestCase(@"pathToFile.xlsx", "TestCase1")] [TestCase(@"pathToFile.xlsx", "TestCase2")] [TestCase(@"pathToFile.xlsx", "TestCase3")] public void performActionsByWorksheet(string excelFilePath,

MemberData tests show up as one test instead of many

大兔子大兔子 提交于 2019-12-03 04:22:47
When you use [Theory] together with [InlineData] it will create a test for each item of inline data that is provided. However, if you use [MemberData] it will just show up as one test. Is there a way to make [MemberData] tests show up as multiple tests? Nate Barbettini I spent a lot of time trying to figure this one out in my project. This related Github discussion from @NPadrutt himself helped a lot, but it was still confusing. The tl;dr is this: [MemberInfo] will report a single group test unless the provided objects for each test can be completely serialized and deserialized by implementing

pass test case parameters using nunit console

一曲冷凌霜 提交于 2019-12-02 23:09:44
I am developing tests using Nunit and data driven testing approach. I have test method with 2 parameters: path to xlsx file and worksheet name. It works perfect in Visual Studio when I pass parameters in TestCase attribute, for example when I want to run 3 test cases have to write something like this: [TestCase(@"pathToFile.xlsx", "TestCase1")] [TestCase(@"pathToFile.xlsx", "TestCase2")] [TestCase(@"pathToFile.xlsx", "TestCase3")] public void performActionsByWorksheet(string excelFilePath, string worksheetName) { //test code } I would like to run my test cases and pass parameters using Nunit

Add a SQL Datasource to a Web Test

早过忘川 提交于 2019-12-02 20:26:37
问题 I am trying to add a SQL Server Data Source to a Web Test in VS2017: I click Install packages and get this: Missing option value: installpath How do I overcome this problem? Edit 1: Using Process Monitor I have identified the command VS2017 runs: "C:\program files (x86)\microsoft visual studio\installer\vs_installer.exe" modify --focusedUi --installPath "" --activityId 6bb6d93d-8c2a-4462-9304-4ef2b29d27d1 --add Microsoft.VisualStudio.Component.SQL.DataSources --includeRecommended The

Add a SQL Datasource to a Web Test

时光总嘲笑我的痴心妄想 提交于 2019-12-02 11:29:46
I am trying to add a SQL Server Data Source to a Web Test in VS2017: I click Install packages and get this: Missing option value: installpath How do I overcome this problem? Edit 1: Using Process Monitor I have identified the command VS2017 runs: "C:\program files (x86)\microsoft visual studio\installer\vs_installer.exe" modify --focusedUi --installPath "" --activityId 6bb6d93d-8c2a-4462-9304-4ef2b29d27d1 --add Microsoft.VisualStudio.Component.SQL.DataSources --includeRecommended The installPath is empty so I specified it as: "C:\Program Files x86\Microsoft Visual Studio\2017\Enterprise

Java TestNG with Data Driven Testing Across Multiple Tests

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-02 08:44:32
I have a series of stores that I am testing in an ecommerce platform, and each store has a series of properties that I am looking at automating a test for. Is it possible to have a data provider that gives data across a test suite instead of just a test in TestNG? I'm trying not to use the testNG.xml file as mechanism because these properties are coming directly from a database call. ["StoreName", "username", "password", "credit-enabled", "items-store", "shipping-location", ] What I need the automation to do is the following: @Test Login with the username and password in the current dataset

Data driven load testing with Visual Studio - where are web tests generated?

廉价感情. 提交于 2019-11-30 09:52:17
问题 I have set up a Web Performance Test and Load Test project in Visual Studio 2013 that uses data driven web tests based on a local SQL Server data source. Eventually I would like to set up a test controller and test agents in order to distribute the load from multiple clients. My question is about the architecture of the controller and agents. Does each test agent also need access to the data source that generates content for the web tests or is the web test (and its dynamic parameters)

Data driven tests generated in ClassInitialize: no longer working in Visual Studio 2012

做~自己de王妃 提交于 2019-11-30 05:27:53
I have upgraded from Visual Studio 2010 to Visual Studio 2012. In my unit test project, I have a [ClassInitialize] method which generates a CSV file which I then feed into a data-driven [TestMethod] using [DataSource] connected to the CSV. This works great in Visual Studio 2010. I cannot get this to work in Visual Studio 2012. It seems that in VS2012 the MS test runner requires the file connected to the [DataSource] to already exist otherwise none of the tests will run. If I create the CSV myself, the data-driven tests run, but they do not pick up the data created in [ClassInitialize]: it