Something similar to NUnit TestCaseSource in Visual Studio unit testing - visual-studio

Is there anything similar to NUnit TestCaseSource attribute in Visual Studio unit testing? The closest solution I found was to use a DataSource. But I don't want to store my test case parameters in a data source.

Datasource is one option to take the test input. You can save your test data in many file format (xml, xls or in sql db)
But if you don't want to store your test data, then use TestInitialize() attribute in any method that will execute before any of your test cases. Save all your test data run time in xml,xls or in sql db through this method and then using datasource use it in your test cases.
Here is msdn link for VSTS unit test. Hope this will help you.

Related

How to create different suites and define their order of execution in Godog?

I want to create different test suites for execution of my test cases. The main idea is that I want to load some sample data into database using a feature file in a single suite. After this suite is completed I want to execute different suite containing the test scenarios. Is it possible in GoDog?
There is an example in DATA-DOG repo https://github.com/DATA-DOG/godog/tree/master/examples/db with DB connection it could be helpful. It gives you an opportunity to roll back inserted data before every scenario or suite if you want.

Any dataprovider available for specflow

Looking for data provider as external file like CSV/Excel, similar to MsTest Unit testing framework. Anybody tried or Any implementation available?
I would wrote a separate method, which would read data from csv/excel file in needed order. And added this method in the step, to call it after from Scenario.
Also, in non-free SpecFlow+ version has plugin for reading from Excel.

Query for Test plan Children

Is there a way in Visual Studio to query for work items by specifying the name or id of the test plan of which they're part?
I have multiple test plans in a single team project so querying on team project alone does not suffice.
As it's not possible to query for all tests by test plan in VS, how are test case linked at database level?
TFS does allow execution of SQL queries using the the MS client libraries using a WorkItemStore instance.
$wiStore = $Collection.GetService([type]"Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore")
$workitems = $wiStore.Query("")
Ultimately I'm attempting to iterate all attachments contained in a test project. Right now this is achieved by retrieving all tests and their (shared) steps and listing their attachments.
Unfortunately,there is no this option in work item queries for now. Example work item queries
Can't find the association between the test plan and test suite (children). The simplest way to query all test suit childrens, you may specify the test suite parent ID {usually =(Test Plan ID+1)}
Update:
I'm not sure if I understood it correctly. If you want to list all tests including the child suite as below. This can be achieved as below.
And it can't be achieved by query for work items in Visual Studio.

How to use Microsoft built in Tests with NHibernate For Repository Layer(DAL)?

Can any body tell me how to use Microsoft built in Tests with NHibernate For Repository Layer(DAL)?
I'm using NUNIT tests to test NH mappings.
you create test (regular) that create objects, updates them and delete them.
Just like any other test - you assert for the results by checking the DB after the operation.
(if you delete an object, you should be able to "get" it... ect...)
I create a session in the beginning of each test, and close it at the end.
same goes to any other function the dal has...
NUnit website

Can MSTest run a specific method each time it startsup?

Question
Is there a way to have a method that will always run anytime that test assembly is run through MSTest?
Similar to how the [TestInitialize] and [ClassInitialize] attributes work, but for the entire assembly. I do not want to have to add code to every test class's [ClassInitialize] method.
Reasoning
Some of my tests interact with the database. They delete data and other things that would be very harmful to a production database. There is only a configuration file that tells my unit test project to run against the non-production database.
I would feel better if there was a method that would run on startup that would say "Okay Database name is not 'production'"
Ideas
Log4Net uses an assembly attribute to configure itself.
using log4net.Config;
[assembly: XmlConfigurator()]
Perhaps I can do something simliar?
[assembly: CheckDatabaseNameNot("production")]
Have you tried [AssemblyInitialize]?

Resources