TestExecutor.cs 851 B

1234567891011121314151617181920212223242526272829303132333435
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.Linq;
  5. using System.Text;
  6. namespace crown_tests.tests
  7. {
  8. public class TestExecutor
  9. {
  10. private TestContainer mContainer;
  11. private String mExeFullFileName;
  12. public TestExecutor(TestContainer container, String exeFullFileName)
  13. {
  14. mContainer = container;
  15. mExeFullFileName = exeFullFileName;
  16. }
  17. public void ExecuteAll()
  18. {
  19. foreach (var category in mContainer.Categories) {
  20. foreach (var test in category.Tests) {
  21. var p = new Process();
  22. p.StartInfo.FileName = mExeFullFileName;
  23. p.StartInfo.Arguments = string.Format("/test:\"{0}\"", test.Name);
  24. p.Start();
  25. p.WaitForExit();
  26. test.LastResult = (p.ExitCode == 0) ? ETestResult.Passed : ETestResult.Failed;
  27. System.Threading.Thread.Sleep(1500);
  28. }
  29. }
  30. }
  31. }
  32. }