Contents
How to test data files for unit testing?
My unit tests rely on an TestInitialize method which pre-loads a data file. The path to this test data file will differ depending on if I run the unit test from within VS 2008 using the standard Ctrl-R + Ctrl-T command versus the Resharper unit test execution command.
Where do I Find my test data files?
The file structure of my test project is that of the standard unit test project created with an MVC application. Under the root of the test project, a new folder was created called ‘Test Data’. It’s this folder I’d like to access regardless of test runner.
Where do I run unit tests in Visual Studio?
In Visual Studio. Resharper -> Options -> Tools -> Unit Testing -> Run Results from: Specified Folder (or change the project output folder of your test project) Where you can specify the folder of your test data, or relative to the specified folder.
Where do I put my test input files?
What I normally do is create a folder in my project (the folder isn’t necessary) and put my test input files there. Then right click on the individual files and go to properties. In the properties, change the “Build Action” to Embedded Resource, and optionally specify a custom tool namespace to make the file easier to find.
Can a unit test access a CSV file?
Or in your case, since the data source is in the test directory: Unit test that access the file system are generally not a good idea. This is because the test should be self contained, by making your test data external to the test it’s no longer immediately obvious which test the csv file belongs to or even if it’s still in use.
How are unit tests different from other tests?
Unit tests don’t deal with their environment and with external systems to the codebase. If it you’ve written something that can fail when run on a machine without the “proper setup,” you haven’t written a unit test. Unit tests also don’t count as other sorts of tests.