Index: pkg/analyzer_cli/test/reporter_test.dart |
diff --git a/pkg/analyzer_cli/test/reporter_test.dart b/pkg/analyzer_cli/test/reporter_test.dart |
index 358b570587ad3f24c9479635e5477e9f8b52c5b4..1ffb2694e634ec49bd6e346106a28bf17b5761f5 100644 |
--- a/pkg/analyzer_cli/test/reporter_test.dart |
+++ b/pkg/analyzer_cli/test/reporter_test.dart |
@@ -5,6 +5,7 @@ |
library analyzer_cli.test.formatter; |
import 'package:analyzer/analyzer.dart'; |
+import 'package:analyzer/src/generated/engine.dart'; |
import 'package:analyzer_cli/src/ansi.dart' as ansi; |
import 'package:analyzer_cli/src/error_formatter.dart'; |
import 'package:test/test.dart' hide ErrorFormatter; |
@@ -14,48 +15,54 @@ import 'mocks.dart'; |
main() { |
group('reporter', () { |
- var out = new StringBuffer(); |
- var stats = new AnalysisStats(); |
+ StringBuffer out; |
+ AnalysisStats stats; |
+ MockCommandLineOptions options; |
+ ErrorFormatter reporter; |
setUp(() { |
ansi.runningTests = true; |
- stats.init(); |
+ |
+ out = new StringBuffer(); |
+ stats = new AnalysisStats(); |
+ |
+ options = new MockCommandLineOptions(); |
+ when(options.enableTypeChecks).thenReturn(false); |
+ when(options.hintsAreFatal).thenReturn(false); |
+ when(options.machineFormat).thenReturn(false); |
+ when(options.verbose).thenReturn(false); |
+ when(options.color).thenReturn(false); |
+ |
+ reporter = new HumanErrorFormatter(out, options, stats); |
}); |
tearDown(() { |
- out.clear(); |
ansi.runningTests = false; |
}); |
- // Options |
- var options = new MockCommandLineOptions(); |
- when(options.enableTypeChecks).thenReturn(false); |
- when(options.hintsAreFatal).thenReturn(false); |
- when(options.machineFormat).thenReturn(false); |
- when(options.verbose).thenReturn(false); |
- when(options.color).thenReturn(false); |
- |
- var reporter = new ErrorFormatter(out, options, stats); |
- |
test('error', () { |
- var error = mockError(ErrorType.SYNTACTIC_ERROR, ErrorSeverity.ERROR); |
+ AnalysisErrorInfo error = |
+ mockError(ErrorType.SYNTACTIC_ERROR, ErrorSeverity.ERROR); |
reporter.formatErrors([error]); |
+ reporter.flush(); |
expect(out.toString().trim(), |
'error • MSG at /foo/bar/baz.dart:3:3 • mock_code'); |
}); |
test('hint', () { |
- var error = mockError(ErrorType.HINT, ErrorSeverity.INFO); |
+ AnalysisErrorInfo error = mockError(ErrorType.HINT, ErrorSeverity.INFO); |
reporter.formatErrors([error]); |
+ reporter.flush(); |
expect(out.toString().trim(), |
'hint • MSG at /foo/bar/baz.dart:3:3 • mock_code'); |
}); |
test('stats', () { |
- var error = mockError(ErrorType.HINT, ErrorSeverity.INFO); |
+ AnalysisErrorInfo error = mockError(ErrorType.HINT, ErrorSeverity.INFO); |
reporter.formatErrors([error]); |
+ reporter.flush(); |
stats.print(out); |
expect( |
out.toString().trim(), |
@@ -83,6 +90,7 @@ MockAnalysisErrorInfo mockError(ErrorType type, ErrorSeverity severity) { |
when(code.name).thenReturn('mock_code'); |
when(error.errorCode).thenReturn(code); |
when(error.message).thenReturn('MSG'); |
+ when(error.offset).thenReturn(20); |
var source = new MockSource(); |
when(source.fullName).thenReturn('/foo/bar/baz.dart'); |
when(error.source).thenReturn(source); |