Reputation: 53
[TestInitialize()]
public void MyTestInitialize()
{
Playback.PlaybackSettings.WaitForReadyLevel = WaitForReadyLevel.Disabled;
Playback.PlaybackSettings.ShouldSearchFailFast = false;
Playback.PlaybackSettings.DelayBetweenActions = 300;
Playback.PlaybackSettings.SearchTimeout = 30000;
Playback.PlaybackSettings.SearchInMinimizedWindows = false;
}
[TestCleanup()]
public void MyTestCleanup()
{
Logger.CreateResultFile(ResultsLog, TestCaseInfo);
}
Is there a way that everytime i create a new codedUI test, the MyTestInitialize() and MyTestCleanup() should be created with above lines in it instead of blank ones?
Upvotes: 1
Views: 259
Reputation: 1324
Creating a base class and let all your other test classes inherit from it. like this:
[CodedUITest]
public class BaseTestClass
{
[TestInitialize()]
public void MyTestInitialize()
{
Playback.PlaybackSettings.WaitForReadyLevel = WaitForReadyLevel.Disabled;
Playback.PlaybackSettings.ShouldSearchFailFast = false;
Playback.PlaybackSettings.DelayBetweenActions = 300;
Playback.PlaybackSettings.SearchTimeout = 30000;
Playback.PlaybackSettings.SearchInMinimizedWindows = false;
}
[TestCleanup()]
public void MyTestCleanup()
{
Console.Write("Do CleanUp");
}
}
[CodedUITest]
public class derivedTestClass : BaseTestClass
{
[TestMethod]
public void Tests()
{
Console.Write("Test");
}
}
when you'll invoke Tests() the init and cleanup methods will be called
Upvotes: 4