diff options
author | Lluis Sanchez <lluis@xamarin.com> | 2017-01-18 13:27:11 +0300 |
---|---|---|
committer | Lluis Sanchez <lluis@xamarin.com> | 2017-01-18 13:27:11 +0300 |
commit | 9c83339303c5c12aa72c7dd871c969f8b96323c1 (patch) | |
tree | 92d493530fb81f7168094fd28b9cc0304b4efd7a /main/src/addins/MonoDevelop.UnitTesting | |
parent | 3e7356f194963afa375c8127124e01af2e992832 (diff) |
[NUnit] Make test store query more robust
If the test store has corrupted data it may throw exceptions when
queried. Those exceptions are now catched and logged.
Fixes bug #44337 - Some test names are not shown in Unit Tests Pad.
Diffstat (limited to 'main/src/addins/MonoDevelop.UnitTesting')
-rw-r--r-- | main/src/addins/MonoDevelop.UnitTesting/Services/UnitTestResultsStore.cs | 62 |
1 files changed, 44 insertions, 18 deletions
diff --git a/main/src/addins/MonoDevelop.UnitTesting/Services/UnitTestResultsStore.cs b/main/src/addins/MonoDevelop.UnitTesting/Services/UnitTestResultsStore.cs index 5cadb15f39..4a0940a90e 100644 --- a/main/src/addins/MonoDevelop.UnitTesting/Services/UnitTestResultsStore.cs +++ b/main/src/addins/MonoDevelop.UnitTesting/Services/UnitTestResultsStore.cs @@ -28,6 +28,7 @@ using System; +using MonoDevelop.Core; namespace MonoDevelop.UnitTesting { @@ -35,41 +36,66 @@ namespace MonoDevelop.UnitTesting { UnitTest test; IResultsStore store; - + internal UnitTestResultsStore (UnitTest test, IResultsStore store) { this.test = test; this.store = store; } - + public UnitTestResult GetLastResult (DateTime date) { - if (store == null) return null; - return store.GetLastResult (test.ActiveConfiguration, test, date); + try { + if (store != null) + return store.GetLastResult (test.ActiveConfiguration, test, date); + } catch (Exception ex) { + LoggingService.LogError ("Test store query failed. Test history data may be corrupt.", ex); + } + return null; } - + public UnitTestResult GetNextResult (DateTime date) { - if (store == null) return null; - return store.GetNextResult (test.ActiveConfiguration, test, date); + try { + if (store != null) + return store.GetNextResult (test.ActiveConfiguration, test, date); + } catch (Exception ex) { + LoggingService.LogError ("Test store query failed. Test history data may be corrupt.", ex); + } + return null; } - + public UnitTestResult GetPreviousResult (DateTime date) { - if (store == null) return null; - return store.GetPreviousResult (test.ActiveConfiguration, test, date); + try { + if (store != null) + return store.GetPreviousResult (test.ActiveConfiguration, test, date); + } catch (Exception ex) { + LoggingService.LogError ("Test store query failed. Test history data may be corrupt.", ex); + } + return null; } - - public UnitTestResult[] GetResults (DateTime startDate, DateTime endDate) + + public UnitTestResult [] GetResults (DateTime startDate, DateTime endDate) { - if (store == null) return new UnitTestResult [0]; - return store.GetResults (test.ActiveConfiguration, test, startDate, endDate); + try { + if (store != null) + return store.GetResults (test.ActiveConfiguration, test, startDate, endDate); + } catch (Exception ex) { + LoggingService.LogError ("Test store query failed. Test history data may be corrupt.", ex); + } + return new UnitTestResult [0]; } - - public UnitTestResult[] GetResultsToDate (DateTime endDate, int count) + + public UnitTestResult [] GetResultsToDate (DateTime endDate, int count) { - if (store == null) return new UnitTestResult [0]; - return store.GetResultsToDate (test.ActiveConfiguration, test, endDate, count); + try { + if (store != null) + return store.GetResultsToDate (test.ActiveConfiguration, test, endDate, count); + } catch (Exception ex) { + LoggingService.LogError ("Test store query failed. Test history data may be corrupt.", ex); + } + return new UnitTestResult [0]; } } } |