data-driven-tests

Duplicate the behaviour of a data driven test

时光总嘲笑我的痴心妄想 提交于 2020-01-04 15:31:14
问题 Right now, if you have a test that looks like this: [TestMethod] [DeploymentItem("DataSource.csv")] [DataSource( Microsoft.VisualStudio.TestTools.DataSource.CSV, "DataSource.csv", "DataSource#csv", DataAccessMethod.Sequential)] public void TestSomething() { string data = TestContext.DataRow["ColumnHeader"].ToString(); /* do something with the data */ } You'll get as many tests runs as you have data values when you execute this test. What I'd like to do is duplicate this kind of behaviour in

Duplicate the behaviour of a data driven test

狂风中的少年 提交于 2020-01-04 15:30:58
问题 Right now, if you have a test that looks like this: [TestMethod] [DeploymentItem("DataSource.csv")] [DataSource( Microsoft.VisualStudio.TestTools.DataSource.CSV, "DataSource.csv", "DataSource#csv", DataAccessMethod.Sequential)] public void TestSomething() { string data = TestContext.DataRow["ColumnHeader"].ToString(); /* do something with the data */ } You'll get as many tests runs as you have data values when you execute this test. What I'd like to do is duplicate this kind of behaviour in

How do I change Unit Test properties through the UI in the newer versions of VS?

别等时光非礼了梦想. 提交于 2019-12-23 18:22:02
问题 A few months ago, when I was reading about datasources in Unit Tests with MSTest, I stumbled on a few old posts, claiming that it was just a matter of going into properties and setting the datasource on the gui. This resulted in the attribute being added to the test method automatically with the required arguments. I was never able to select a unit test on the property grid though, and wondered what these people were talking about. Recently, I learned that this was a feature of the past, and

Data driven unit tests problem

大兔子大兔子 提交于 2019-12-23 16:47:55
问题 I'm having some troubles getting my unit tests to be setup to use an Excel .xlsx data source. My App.config file: <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="microsoft.visualstudio.testtools" type="Microsoft.VisualStudio.TestTools.UnitTesting.TestConfigurationSection, Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/> </configSections> <connectionStrings> <add name="TestData"

Data-driven unit testing - Problem with CSV encoding?

我的未来我决定 提交于 2019-12-23 08:35:40
问题 I have the following CSV file that is used in my data-driven unit test: File;expected Resources.resx;default Resources.de.resx;de AttachmentDetail.ascx.it.resx;it SomeOtherFile.rm-CH.resx;rm-CH "File" and "expected" are the header. But if I want to get the "File"-column in the code like TestContext.DataRow["File"].ToString(); I get the error System.ArgumentException: Column 'File' does not belong to table .. When I add the CSV file to an existing test-case over the test-method properties, it

MSTest data driven Test set DisplayName for Rows from DataSource

白昼怎懂夜的黑 提交于 2019-12-23 07:06:04
问题 How can I set the DisplayName of a Data Row in data driven tests, where the data source is a XML and the provider is Microsoft.VisualStudio.TestTools.DataSource.XML. XML: <?xml version="1.0" encoding="utf-8" ?> <environments> <environment><name>IE</name></environment> <environment><name>Chrome</name></environment> </environments> App Config: <!-- CONNECTION STRINGS SETTINGS --> <connectionStrings> <add name="IE_Chrome" connectionString="IE_Chrome.xml" providerName="Microsoft.VisualStudio

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

心不动则不痛 提交于 2019-12-18 12:08:02
问题 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

Possible to pass parameters to TestNG DataProvider?

人走茶凉 提交于 2019-12-17 22:19:25
问题 We would like to run some of our tests each against a set of data values, verifying that the same conditions hold true for each. The data is currently stored in either flat files or in simple Excel spreadsheets. My first thought was to create a TestNG DataProvider that would load the data from the file and be used to call the test method once for each data value. My problem is that different tests need to load data from different files and there doesn't appear to be any way to send a

How to run a test many times with data read from .csv file (data driving)

给你一囗甜甜゛ 提交于 2019-12-17 02:32:15
问题 I am trying to automate some testing for one of our web applications and I need to know how I can make my Coded UI project read data from a CSV file. Lets say I want to test a log in screen. My CSV file will contain a few user names and passwords. I want my Coded UI test to read these log in details and loop through them to run the test on each set of data. 回答1: The web has many tutorials on data driving Coded UI tests. The basic steps for data driving with a CSV file are as follows. Create

Adding test methods dynamically using decorator

爷,独闯天下 提交于 2019-12-13 05:16:59
问题 I've been using DDT to parameterize my tests with great success for the past few months. My issue now is that I can't seem to inject a list variable as my data source. Doing so seems to confuse DDT causing it to not parameterize my tests. I started to create my own solution, but I can't seem to figure this last part out. Here is what I have thus far as decorators - def data(*values): def aaa(func): def wrapper(self, *args, **kwargs): pass # return func(self, *args, **kwargs) wrapper.func_name