Skip to content

Instantly share code, notes, and snippets.

Avatar
😎
just an enjoyer

Bartek Pacia bartekpacia

😎
just an enjoyer
View GitHub Profile
@bartekpacia
bartekpacia / callbacks_test.dart
Created September 21, 2023 11:40
A mini-example of executing a single Dart test with its lifecycle callbacks.
View callbacks_test.dart
import 'package:flutter_test/flutter_test.dart';
import 'package:patrol/src/extensions.dart';
// ignore: depend_on_referenced_packages
import 'package:test_api/src/backend/invoker.dart';
const String requestedTest = 'groupA testA';
String get currentTest => Invoker.current!.fullCurrentTestName();
void main() {
@bartekpacia
bartekpacia / intro_permissions_1.dart
Last active September 19, 2023 14:20
Flutter Silesia #6 snippets
View intro_permissions_1.dart
PatrolTester $;
$.native.grantPermissionWhenInUse()
$.native.grantPermissionOnlyThisTime();
$.native.denyPermission();
@bartekpacia
bartekpacia / main.dart
Last active August 11, 2023 11:42
Nested groups and test cases example.
View main.dart
class DartTestGroup {
String name = '';
List<DartTestCase> tests = [];
List<DartTestGroup> groups = [];
DartTestGroup({
required this.name,
this.tests = const [],
this.groups = const [],
});
View Part 1 - verbose code 1.dart
testWidgets('signs up', (WidgetTester tester) async {
await tester.pumpWidget(ExampleApp());
await tester.pumpAndSettle();
await tester.enterText(
find.byKey(Key('emailTextField')),
'charlie@root.me',
);
await tester.pumpAndSettle();
await tester.enterText(
find.byKey(Key('nameTextField')),
@bartekpacia
bartekpacia / carbon-width-80
Last active September 14, 2023 10:26
My Carbon config for Dart code.
View carbon-width-80
{
"paddingVertical": "0px",
"paddingHorizontal": "0px",
"backgroundImage": null,
"backgroundImageSelection": null,
"backgroundMode": "color",
"backgroundColor": "rgba(171, 184, 195, 1)",
"dropShadow": false,
"dropShadowOffsetY": "20px",
"dropShadowBlurRadius": "68px",
@bartekpacia
bartekpacia / test_bundle.dart
Created May 16, 2023 12:56
File generated by Patrol CLI for the "integration_test" directory with 2 test files.
View test_bundle.dart
// ignore_for_file: invalid_use_of_internal_member,
// depend_on_referenced_packages, directives_ordering
import 'dart:async';
import 'package:flutter_test/flutter_test.dart';
import 'package:patrol/patrol.dart';
import 'package:patrol/src/native/contracts/contracts.pbgrpc.dart';
import 'package:test_api/src/backend/invoker.dart';
@bartekpacia
bartekpacia / RunnerTests.m
Last active August 7, 2023 13:35
This snippet shows how to dynamically create test cases in XCTest.
View RunnerTests.m
@import XCTest;
@import ObjectiveC.runtime;
@interface ParametrizedTests : XCTestCase
@end
@implementation ParametrizedTests
+ (NSArray<NSInvocation *> *)testInvocations {
NSLog(@"testInvocations() called");
@bartekpacia
bartekpacia / file.m
Created April 26, 2023 22:21
$ clang -framework Foundation file.m -o file
View file.m
#import <Foundation/Foundation.h>
@interface PatrolIntegrationTestRunner : NSObject
+ (NSString *)createMethodNameFromPatrolGeneratedGroup:(NSString *)dartTestGroup;
@end
@implementation PatrolIntegrationTestRunner
- (instancetype)init {
self = [super init];
@bartekpacia
bartekpacia / ContractsExtensions.kt
Last active April 22, 2023 20:21
patrol bundling stuff
View ContractsExtensions.kt
fun DartTestGroup.listFlatDartFiles(): List<String> {
val files = mutableListOf<String>()
for (group in groupsList) {
files.addAll(group.listGroups())
}
return files.filter { it.endsWith(".dart") }
}
// Recursively lists groups in this group.
private fun DartTestGroup.listGroups(): List<String> {
@bartekpacia
bartekpacia / cmd_1
Last active July 22, 2023 16:51
Decode test-results.pb file generated by ./gradlew connectedAndroidTest
View cmd_1
# display in protoc "text format" without keys
protoc --decode_raw < test-result.pb