Skip to content

Commit 00938f9

Browse files
author
Gilles Grousset
committed
fix(Test): updated unit test
1 parent a295607 commit 00938f9

File tree

5 files changed

+59
-13
lines changed

5 files changed

+59
-13
lines changed

.github/workflows/analyze.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
- main
77

88
jobs:
9-
build:
9+
analyze:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: 📚 Git Checkout

coverage/lcov.info

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
SF:lib/main.dart
2+
DA:4,0
3+
DA:5,0
4+
DA:9,1
5+
DA:11,0
6+
DA:13,0
7+
DA:15,0
8+
DA:16,0
9+
DA:19,0
10+
DA:20,0
11+
DA:29,2
12+
DA:33,0
13+
DA:34,0
14+
DA:35,0
15+
DA:39,1
16+
DA:41,1
17+
DA:42,1
18+
DA:43,3
19+
DA:44,2
20+
DA:46,1
21+
DA:47,1
22+
DA:49,1
23+
DA:52,1
24+
DA:53,0
25+
DA:54,0
26+
DA:60,1
27+
DA:61,0
28+
DA:62,0
29+
DA:63,0
30+
LF:28
31+
LH:12
32+
end_of_record

sonar-project.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ sonar.projectVersion=1.0
88
# Use commas to specify more than one file/folder.
99
# It is good practice to add pubspec.yaml to the sources as the analyzer
1010
# may produce warnings for this file as well.
11-
sonar.sources=lib,pubspec.yaml
11+
sonar.sources=lib
1212
sonar.tests=test
1313

1414
# Encoding of the source code. Default is default system encoding.

test/widget_test.dart

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,23 @@ import 'package:flutter_test/flutter_test.dart';
1111
import 'package:sonar_flutter_example/main.dart';
1212

1313
void main() {
14-
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
14+
testWidgets('MyHomePage widget test', (WidgetTester tester) async {
1515
// Build our app and trigger a frame.
16-
await tester.pumpWidget(const MyApp());
16+
await tester.pumpWidget(const MaterialApp(
17+
home: MyHomePage(title: 'Test Title'),
18+
));
1719

18-
// Verify that our counter starts at 0.
19-
expect(find.text('0'), findsOneWidget);
20-
expect(find.text('1'), findsNothing);
20+
// Verify that the title is correct
21+
expect(find.text('Test Title'), findsOneWidget);
2122

22-
// Tap the '+' icon and trigger a frame.
23-
await tester.tap(find.byIcon(Icons.add));
24-
await tester.pump();
23+
// Verify that the main text is present
24+
expect(find.text('Like sonar-flutter plugin?'), findsOneWidget);
2525

26-
// Verify that our counter has incremented.
27-
expect(find.text('0'), findsNothing);
28-
expect(find.text('1'), findsOneWidget);
26+
// Verify that both buttons are present
27+
expect(find.text('Give it a star on GitHub'), findsOneWidget);
28+
expect(find.text('Sponsor us on GitHub'), findsOneWidget);
29+
30+
// Verify that there are two ElevatedButtons
31+
expect(find.byType(ElevatedButton), findsNWidgets(2));
2932
});
3033
}

tests.output

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{"protocolVersion":"0.1.1","runnerVersion":null,"pid":45667,"type":"start","time":0}
2+
{"suite":{"id":0,"platform":"vm","path":"/Users/ggrousset/Projects/insideapp/sonar_flutter_example/test/widget_test.dart"},"type":"suite","time":0}
3+
{"test":{"id":1,"name":"loading /Users/ggrousset/Projects/insideapp/sonar_flutter_example/test/widget_test.dart","suiteID":0,"groupIDs":[],"metadata":{"skip":false,"skipReason":null},"line":null,"column":null,"url":null},"type":"testStart","time":1}
4+
{"count":1,"time":8,"type":"allSuites"}
5+
6+
[{"event":"test.startedProcess","params":{"vmServiceUri":"http://127.0.0.1:53834/xxdAO0r7bMY=/","observatoryUri":"http://127.0.0.1:53834/xxdAO0r7bMY=/"}}]
7+
{"testID":1,"result":"success","skipped":false,"hidden":true,"type":"testDone","time":2329}
8+
{"group":{"id":2,"suiteID":0,"parentID":null,"name":"","metadata":{"skip":false,"skipReason":null},"testCount":1,"line":null,"column":null,"url":null},"type":"group","time":2332}
9+
{"test":{"id":3,"name":"MyHomePage widget test","suiteID":0,"groupIDs":[2],"metadata":{"skip":false,"skipReason":null},"line":171,"column":5,"url":"package:flutter_test/src/widget_tester.dart","root_line":14,"root_column":3,"root_url":"file:///Users/ggrousset/Projects/insideapp/sonar_flutter_example/test/widget_test.dart"},"type":"testStart","time":2333}
10+
{"testID":3,"result":"success","skipped":false,"hidden":false,"type":"testDone","time":3257}
11+
{"success":true,"type":"done","time":3908}

0 commit comments

Comments
 (0)