c# - How to set universal path in method's attribute -
i wrote test. use data driven unit tests. method declaration looks follow:
[testcategory("integrationtest")] [datasource("microsoft.visualstudio.testtools.datasource.csv", "c:\\myprojectpath\\file.csv", "file#csv", dataaccessmethod.sequential), deploymentitem("file.csv"), testmethod] public void read_csv_file_attribute()
i want commit changes source control. problem have hardcoded path in datasource attribute: "c:\myprojectpath\file.csv".
if latest version of code repository person have change path in attribute.
how make universal path work c-workers?
i've tried change path using:
methodinfo method = typeof(testclass).getmethod("read_csv_file_attribute"); method.customattributes.elementat(1).constructorarguments.elementat(1).value = _newpath;
it doesn't work because value read-only.
[testcategory("integrationtest")] [datasource("microsoft.visualstudio.testtools.datasource.csv", path.combine(), "file#csv", dataaccessmethod.sequential), deploymentitem("file.csv"), testmethod] public void read_csv_file_attribute()
combine() throws message: cannot resolve symbole 'combine'.
i tried use configurationmanager class, information: class name not valid @ point.
include file.csv project , copy output directory (right click on file.csv in solution => properties => advanced => copy output directory => copy if newer)
use relative path "file.csv" in
datasourceattribute
:[datasource("microsoft.visualstudio.testtools.datasource.csv", "file.csv", "file#csv", dataaccessmethod.sequential)]
Comments
Post a Comment