问题
Each test case saves results to a separate UITestActionLog.html file. But in the end of each test case I'd like to move that .html to a different folder and rename it.
Is it possible to do so in, say, [TestCleanup()]? If yes, then how can I programmatically get .html report location?
回答1:
The TestContext
class contains several fields with "directory" in their names. These can be used to access the various directories associated with running the tests.
As well as managing the files as asked by your question the TestContext
class has an AddResultFile
method. The Microsoft documentation on this mehod is not clear, but it seems that the files are saved for failing tests and discarded for passing tests.
回答2:
To get the directory in which the UITestActionLog file will be located, use the TestContext.TestResultsDirectory
Property. You can use below code to get the full path:
string fullPath = TestContext.TestResultsDirectory +"\" +"UITestActionLog.html";
来源:https://stackoverflow.com/questions/19682034/how-to-get-path-to-uitestactionlog-html-from-code