Skip to content

Commit

Permalink
Log error when file not found
Browse files Browse the repository at this point in the history
  • Loading branch information
mmanela committed Sep 2, 2016
1 parent 7dfb5aa commit d5174a5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Chutzpah/Callbacks/ITestMethodRunnerCallback.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public interface ITestMethodRunnerCallback
/// </summary>
/// <param name="exception"></param>
/// <param name="fileName"></param>
void ExceptionThrown(Exception exception, string fileName);
void ExceptionThrown(Exception exception, string fileName=null);

/// <summary>
/// An error that occurred in a test file
Expand Down
12 changes: 10 additions & 2 deletions Chutzpah/Callbacks/RunnerCallback.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,17 @@ protected virtual string GetFileLogMessage(TestLog log)
return string.Format("Log Message: {0} from {1}\n", log.Message, log.InputTestFile);
}

protected virtual string GetExceptionThrownMessage(Exception exception, string fileName)
protected virtual string GetExceptionThrownMessage(Exception exception, string fileName=null)
{
return string.Format("Chutzpah Error: {0} - {1}\n While Running:{2}\n\n", exception.GetType().Name, exception, fileName);
if (!string.IsNullOrEmpty(fileName))
{
return string.Format("Chutzpah Error: {0}\n While Running:{1}\n\n", exception, fileName);
}
else
{

return string.Format("Chutzpah Error: {0}\n\n", exception);
}
}

public static string FormatFileErrorMessage(TestError error)
Expand Down
5 changes: 5 additions & 0 deletions Chutzpah/TestRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,11 @@ private bool PerformBatchCompile(ITestMethodRunnerCallback callback, IEnumerable
{
batchCompilerService.Compile(testContexts);
}
catch (FileNotFoundException e)
{
callback.ExceptionThrown(e);
return false;
}
catch (ChutzpahCompilationFailedException e)
{
callback.ExceptionThrown(e, e.SettingsFile);
Expand Down

0 comments on commit d5174a5

Please sign in to comment.