My aim is to restore an Oracle database back to it's previous state after a lot of unit tests have been run by using flashback recovery using the ClassCleanup attribute.
I have written a batch file + SQL to properly restore the database. This has been tested in my command prompt numerous times without issues
I would normally put the restore as a cleanup script inside the test run configuration, however I need to include a time to flashback the database to (set on the ClassInitialize)
try
{
ProcessStartInfo startInfo = new ProcessStartInfo(@"SomeProjectDirectory\flashback.bat");
startInfo.CreateNoWindow = false;
startInfo.WindowStyle = ProcessWindowStyle.Normal;
startInfo.ErrorDialog = true;
startInfo.Arguments = Arguments;
startInfo.UseShellExecute = true;
Process batchExecute = new Process();
batchExecute.StartInfo = startInfo;
batchExecute.Start();
batchExecute.WaitForExit();
}
catch (Exception e)
{
System.Diagnostics.Debug.WriteLine(e.ToString());
}
The batch file is executed fine but the problem seems to be that the ClassCleanup method times out before it has finished
It does not hit any breakpoints or catch any exceptions after the WaitForExit(). It simply exits the command prompt window halfway through the process and lets me know all the tests succeeded with no error message.
I tried adding a Timeout attribute to the ClassCleanup method with a large number but this doesn't seem to help either. This attribute I am fairly certain is only applicable to a unit test not the class cleanup
I moved the process into the TestCleanup method and it worked without a problem. The process also ran fine inside a Test. It only seems to timeout in the ClassCleanup & AssemblyCleanup methods
I am under the impression that is a timeout because everytime we run the test, it always drops out at the same point, however if we add or remove steps to the script, it will drop out earlier or later than normal