-
Notifications
You must be signed in to change notification settings - Fork 8
follow documentation for patrol #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
6a6a945
d66e204
f5a9dfe
e18ee42
52fe077
dba7a73
c0513cb
4e9baa4
2179226
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
# This is a generated file; do not edit or check into version control. | ||
integration_test=/opt/homebrew/Caskroom/flutter/2.5.3/flutter/packages/integration_test/ | ||
patrol=/Users/smalugu/.pub-cache/git/patrol-168113aeb798d3528e296d3bc9785df3778c51ba/packages/patrol/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,39 @@ | ||
package com.example.house_stats; | ||
|
||
import androidx.test.rule.ActivityTestRule; | ||
import dev.flutter.plugins.integration_test.FlutterTestRunner; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Parameterized; | ||
import org.junit.runners.Parameterized.Parameters; | ||
import pl.leancode.patrol.ContractsExtensionsKt; | ||
import pl.leancode.patrol.Logger; | ||
import pl.leancode.patrol.PatrolJUnitRunner; | ||
|
||
@RunWith(FlutterTestRunner.class) | ||
import java.util.Arrays; | ||
|
||
import static pl.leancode.patrol.contracts.Contracts.DartTestGroup; | ||
|
||
@RunWith(Parameterized.class) | ||
public class MainActivityTest { | ||
@Rule | ||
public ActivityTestRule<MainActivity> rule = new ActivityTestRule<>(MainActivity.class, true, false); | ||
@Parameters(name = "{0}") | ||
public static Object[] testCases() { | ||
DartTestGroup dartTestGroup = PatrolJUnitRunner.setUp(); | ||
|
||
Object[] dartTestFiles = ContractsExtensionsKt.listFlatDartFiles(dartTestGroup).toArray(); | ||
Logger.INSTANCE.i("MainActivityTest.testCases(): Got Dart test files: " + Arrays.toString(dartTestFiles)); | ||
return dartTestFiles; | ||
} | ||
|
||
public MainActivityTest(String dartTestName) { | ||
this.dartTestName = dartTestName; | ||
} | ||
|
||
private final String dartTestName; | ||
|
||
@Test | ||
public void runDartTest() { | ||
Logger.INSTANCE.i("MainActivityTest.runDartTest(): " + dartTestName); | ||
|
||
// Run a test and wait for it to finish. Throws AssertionError if the test fails. | ||
PatrolJUnitRunner.runDartTest(dartTestName); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:house_stats/main.dart'; | ||
import 'package:patrol/patrol.dart'; | ||
|
||
main() { | ||
patrolTest( | ||
'house place widget shows red color for first place', | ||
($) async { | ||
await $.pumpWidgetAndSettle( | ||
const HouseStatsApp(), | ||
); | ||
|
||
expect($('1house'), findsOneWidget); | ||
expect($('10'), findsOneWidget); | ||
await $('1house').tap(); | ||
|
||
expect($('House details'), findsOneWidget); | ||
expect($('1house'), findsOneWidget); | ||
}, | ||
nativeAutomation: true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's because you're using Dart older than 2.17. https://dart.dev/guides/language/evolution#dart-217
|
||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,22 @@ | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:house_stats/main.dart'; | ||
import 'package:integration_test/integration_test.dart'; | ||
import 'package:patrol/patrol.dart'; | ||
|
||
main() { | ||
IntegrationTestWidgetsFlutterBinding.ensureInitialized(); | ||
testWidgets('Integration testing house dashboard', (tester) async { | ||
await tester.pumpWidget(const HouseStatsApp()); | ||
await tester.pumpAndSettle(); | ||
patrolTest( | ||
'house place widget shows red color for first place', | ||
($) async { | ||
await $.pumpWidgetAndSettle( | ||
const HouseStatsApp(), | ||
); | ||
|
||
expect(find.text('1house'), findsOneWidget); | ||
expect(find.text('10'), findsOneWidget); | ||
await tester.tap(find.text('1house')); | ||
await tester.pumpAndSettle(); | ||
expect($('1house'), findsOneWidget); | ||
expect($('10'), findsOneWidget); | ||
await $('1house').tap(); | ||
|
||
expect(find.text('House details'), findsOneWidget); | ||
expect(find.text('1house'), findsOneWidget); | ||
}); | ||
expect($('House details'), findsOneWidget); | ||
expect($('1house'), findsOneWidget); | ||
}, | ||
nativeAutomation: true, | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
had to add it for multidex