Using files in C# unit testing
In order to use files during unit testing, the files must be added in the unit test project as shown below,
The file should be available in the deployment folder for test methods to access. In order to achieve that, browse to Test -> Edit Test Settings -> Local.testsettings in Visual Studio menu. Test Settings window will be displayed as shown below,
Go to Deployment and Check ‘Enable Deployment’. Now add the file(s) (from test project folder) using the “Add File…” button.
Now, when test is running, the file will be available in the deployment directory and it can be accessed using TestContext.DeploymentDirectory.
No comments yet.