Jonatas

split tests

Showing 31 changed files with 302 additions and 149 deletions
... ... @@ -4,12 +4,12 @@ name: build
on:
push:
paths:
- "getx/**"
- "/**"
- ".github/workflows/main.yaml"
pull_request:
paths:
- "getx/**"
- "/**"
- ".github/workflows/main.yaml"
#A workflow run is made up of one or more jobs. Jobs run in parallel by default.
jobs:
... ...
... ... @@ -4,19 +4,22 @@ name: build
on:
push:
paths:
- "packages/get_core/**"
- ".github/workflows/packages.yaml"
- "/**"
- ".github/workflows/get_instance.yaml"
pull_request:
paths:
- "packages/get_core/**"
- ".github/workflows/packages.yaml"
- "/**"
- ".github/workflows/get_instance.yaml"
#A workflow run is made up of one or more jobs. Jobs run in parallel by default.
jobs:
test:
#The type of machine to run the job on. [windows,macos, ubuntu , self-hosted]
runs-on: macos-latest
defaults:
run:
working-directory: packages/get_instance
runs-on: ubuntu-latest
#sequence of tasks called
steps:
# The branch or tag ref that triggered the workflow will be checked out.
... ...
#The name of your workflow.
name: build
# Trigger the workflow on push or pull request
on:
push:
paths:
- "/**"
- ".github/workflows/get_navigation.yaml"
pull_request:
paths:
- "/**"
- ".github/workflows/get_navigation.yaml"
#A workflow run is made up of one or more jobs. Jobs run in parallel by default.
jobs:
test:
#The type of machine to run the job on. [windows,macos, ubuntu , self-hosted]
defaults:
run:
working-directory: packages/get_navigation
runs-on: ubuntu-latest
#sequence of tasks called
steps:
# The branch or tag ref that triggered the workflow will be checked out.
# https://github.com/actions/checkout
- uses: actions/checkout@v1
# Setup a flutter environment.
# https://github.com/marketplace/actions/flutter-action
- uses: subosito/flutter-action@v1
with:
flutter-version: '1.20.4'
channel: 'stable'
- run: flutter pub get
#- run: flutter analyze
# run flutter widgets tests and unit tests
- run: flutter test --coverage
# Upload coverage reports to Codecov
# https://github.com/marketplace/actions/codecov
- uses: codecov/codecov-action@v1.0.7
... ...
#The name of your workflow.
name: build
# Trigger the workflow on push or pull request
on:
push:
paths:
- "/**"
- ".github/workflows/get_rx.yaml"
pull_request:
paths:
- "/**"
- ".github/workflows/get_rx.yaml"
#A workflow run is made up of one or more jobs. Jobs run in parallel by default.
jobs:
test:
#The type of machine to run the job on. [windows,macos, ubuntu , self-hosted]
defaults:
run:
working-directory: packages/get_rx
runs-on: ubuntu-latest
#sequence of tasks called
steps:
# The branch or tag ref that triggered the workflow will be checked out.
# https://github.com/actions/checkout
- uses: actions/checkout@v1
# Setup a flutter environment.
# https://github.com/marketplace/actions/flutter-action
- uses: subosito/flutter-action@v1
with:
flutter-version: '1.20.4'
channel: 'stable'
- run: flutter pub get
#- run: flutter analyze
# run flutter widgets tests and unit tests
- run: flutter test --coverage
# Upload coverage reports to Codecov
# https://github.com/marketplace/actions/codecov
- uses: codecov/codecov-action@v1.0.7
... ...
#The name of your workflow.
name: build
# Trigger the workflow on push or pull request
on:
push:
paths:
- "/**"
- ".github/workflows/get_state_manager.yaml"
pull_request:
paths:
- "/**"
- ".github/workflows/get_state_manager.yaml"
#A workflow run is made up of one or more jobs. Jobs run in parallel by default.
jobs:
test:
#The type of machine to run the job on. [windows,macos, ubuntu , self-hosted]
defaults:
run:
working-directory: packages/get_state_manager
runs-on: ubuntu-latest
#sequence of tasks called
steps:
# The branch or tag ref that triggered the workflow will be checked out.
# https://github.com/actions/checkout
- uses: actions/checkout@v1
# Setup a flutter environment.
# https://github.com/marketplace/actions/flutter-action
- uses: subosito/flutter-action@v1
with:
flutter-version: '1.20.4'
channel: 'stable'
- run: flutter pub get
#- run: flutter analyze
# run flutter widgets tests and unit tests
- run: flutter test --coverage
# Upload coverage reports to Codecov
# https://github.com/marketplace/actions/codecov
- uses: codecov/codecov-action@v1.0.7
... ...
#The name of your workflow.
name: build
# Trigger the workflow on push or pull request
on:
push:
paths:
- "/**"
- ".github/workflows/get_utils.yaml"
pull_request:
paths:
- "/**"
- ".github/workflows/get_utils.yaml"
#A workflow run is made up of one or more jobs. Jobs run in parallel by default.
jobs:
test:
#The type of machine to run the job on. [windows,macos, ubuntu , self-hosted]
defaults:
run:
working-directory: packages/get_utils
runs-on: ubuntu-latest
#sequence of tasks called
steps:
# The branch or tag ref that triggered the workflow will be checked out.
# https://github.com/actions/checkout
- uses: actions/checkout@v1
# Setup a flutter environment.
# https://github.com/marketplace/actions/flutter-action
- uses: subosito/flutter-action@v1
with:
flutter-version: '1.20.4'
channel: 'stable'
- run: flutter pub get
#- run: flutter analyze
# run flutter widgets tests and unit tests
- run: flutter test --coverage
# Upload coverage reports to Codecov
# https://github.com/marketplace/actions/codecov
- uses: codecov/codecov-action@v1.0.7
... ...
import 'package:flutter_test/flutter_test.dart';
import 'package:get/get.dart';
import 'util/matcher.dart';
class Mock {
static Future<String> test() async {
await Future.delayed(Duration.zero);
return 'test';
}
}
class Controller {}
class DisposableController extends DisposableInterface {
bool initialized = false;
void onInit() async {
initialized = true;
}
}
// ignore: one_member_abstracts
abstract class Service {
String post();
}
class Api implements Service {
@override
String post() {
return 'test';
}
}
void main() {
test('Get.putAsync test', () async {
await Get.putAsync<String>(Mock.test);
expect('test', Get.find<String>());
Get.reset();
});
test('Get.put test', () async {
final instance = Get.put<Controller>(Controller());
expect(instance, Get.find<Controller>());
Get.reset();
});
test('Get.lazyPut test', () async {
final controller = Controller();
Get.lazyPut<Controller>(() => controller);
final ct1 = Get.find<Controller>();
expect(ct1, controller);
Get.reset();
});
test('Get.lazyPut with abstract class test', () async {
final api = Api();
Get.lazyPut<Service>(() => api);
final ct1 = Get.find<Service>();
expect(ct1, api);
Get.reset();
});
test('Get.create with abstract class test', () async {
Get.create<Service>(() => Api());
final ct1 = Get.find<Service>();
final ct2 = Get.find<Service>();
expect(ct1 is Service, true);
expect(ct2 is Service, true);
expect(ct1 == ct2, false);
Get.reset();
});
group('test put, delete and check onInit execution', () {
tearDownAll(Get.reset);
test('Get.put test with init check', () async {
final instance = Get.put<DisposableController>(DisposableController());
expect(instance, Get.find<DisposableController>());
expect(instance.initialized, true);
});
test('Get.delete test with disposable controller', () async {
expect(await Get.delete<DisposableController>(), true);
expect(() => Get.find<DisposableController>(),
throwsA(TypeMatcher<String>()));
});
test('Get.put test after delete with disposable controller and init check',
() async {
final instance = Get.put<DisposableController>(DisposableController());
expect(instance, Get.find<DisposableController>());
expect(instance.initialized, true);
});
});
}
void main() {
// testWidgets("Get.dialog close test", (tester) async {
// await tester.pumpWidget(
// Wrapper(child: Container()),
// );
// expect(Get.isDarkMode, false);
// Get.changeTheme(ThemeData.dark());
// await Future.delayed(Duration.zero);
// expect(Get.isDarkMode, true);
// await tester.pumpAndSettle();
// });
}
... ... @@ -11,8 +11,10 @@ environment:
dependencies:
get_core:
path: ../get_core
dev_dependencies:
test: ">=1.0.0 <2.0.0"
# For information on the generic Dart part of this file, see the
... ...
void main() {}
import 'package:get_instance/get_instance.dart';
import 'package:test/test.dart';
import 'package:get_core/get_core.dart';
import 'util/matcher.dart' as m;
class Mock {
static Future<String> test() async {
await Future.delayed(Duration.zero);
return 'test';
}
}
class Controller {}
class DisposableController extends GetLifeCycle {
bool initialized = false;
void onInit() async {
initialized = true;
}
}
// ignore: one_member_abstracts
abstract class Service {
String post();
}
class Api implements Service {
@override
String post() {
return 'test';
}
}
void main() {
test('Get.putAsync test', () async {
await Get.putAsync<String>(Mock.test);
expect('test', Get.find<String>());
Get.reset();
});
test('Get.put test', () async {
final instance = Get.put<Controller>(Controller());
expect(instance, Get.find<Controller>());
Get.reset();
});
test('Get.lazyPut test', () async {
final controller = Controller();
Get.lazyPut<Controller>(() => controller);
final ct1 = Get.find<Controller>();
expect(ct1, controller);
Get.reset();
});
test('Get.lazyPut with abstract class test', () async {
final api = Api();
Get.lazyPut<Service>(() => api);
final ct1 = Get.find<Service>();
expect(ct1, api);
Get.reset();
});
test('Get.create with abstract class test', () async {
Get.create<Service>(() => Api());
final ct1 = Get.find<Service>();
final ct2 = Get.find<Service>();
expect(ct1 is Service, true);
expect(ct2 is Service, true);
expect(ct1 == ct2, false);
Get.reset();
});
group('test put, delete and check onInit execution', () {
tearDownAll(Get.reset);
test('Get.put test with init check', () async {
final instance = Get.put<DisposableController>(DisposableController());
expect(instance, Get.find<DisposableController>());
expect(instance.initialized, true);
});
test('Get.delete test with disposable controller', () async {
expect(await Get.delete<DisposableController>(), true);
expect(() => Get.find<DisposableController>(),
throwsA(m.TypeMatcher<String>()));
});
test('Get.put test after delete with disposable controller and init check',
() async {
final instance = Get.put<DisposableController>(DisposableController());
expect(instance, Get.find<DisposableController>());
expect(instance.initialized, true);
});
});
}
... ...
import 'package:flutter_test/flutter_test.dart';
import 'package:test/test.dart';
// Copyright 2014, the Dart project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
... ...
library get_navigation;
export 'package:get_core/get_core.dart';
export 'src/bottomsheet/bottomsheet.dart';
export 'src/extension_navigation.dart';
export 'src/root/root_widget.dart';
... ...
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:get/get.dart';
import 'util/wrapper.dart';
import 'package:get_navigation/get_navigation.dart';
import 'utils/wrapper.dart';
void main() {
testWidgets("Get.bottomSheet smoke test", (tester) async {
... ...
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:get/get.dart';
import 'util/wrapper.dart';
import 'package:get_navigation/get_navigation.dart';
import 'utils/wrapper.dart';
void main() {
testWidgets("Get.defaultDialog smoke test", (tester) async {
... ...
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:get/get.dart';
import 'package:get_core/get_core.dart';
import 'package:get_navigation/get_navigation.dart';
import 'util/wrapper.dart';
import 'utils/wrapper.dart';
class SizeTransitions extends CustomTransition {
@override
... ...
import 'package:flutter_test/flutter_test.dart';
void main() {
test('adds one to input values', () {});
}
import 'package:flutter_test/flutter_test.dart';
import 'package:get/get.dart';
import 'package:get_navigation/get_navigation.dart';
void main() {
testWidgets(
... ...
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:get/get.dart';
import 'package:get_navigation/get_navigation.dart';
void main() {
testWidgets(
... ...
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:get_navigation/get_navigation.dart';
class Wrapper extends StatelessWidget {
final Widget child;
... ...
... ... @@ -17,4 +17,5 @@ dependencies:
dev_dependencies:
test: ">=1.0.0 <2.0.0"
 
\ No newline at end of file
... ...
import 'package:flutter_test/flutter_test.dart';
import 'package:get/get.dart';
import 'package:get_rx/get_rx.dart';
import 'package:test/test.dart';
void main() {
test('once', () async {
... ...
library get_state_manager;
export 'package:get_instance/get_instance.dart';
export 'package:get_rx/get_rx.dart';
export 'src/rx_flutter/rx_disposable.dart';
export 'src/rx_flutter/rx_getx_widget.dart';
export 'src/rx_flutter/rx_obx_widget.dart';
... ...
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:get/get.dart';
import 'package:get_core/get_core.dart';
import 'package:get_instance/get_instance.dart';
import 'package:get_state_manager/get_state_manager.dart';
void main() {
testWidgets("MixinBuilder smoke test", (tester) async {
... ...
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:get/get.dart';
import 'package:get_core/get_core.dart';
import 'package:get_instance/get_instance.dart';
import 'package:get_state_manager/get_state_manager.dart';
void main() {
final controller = Get.put(Controller());
... ...
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:get/get.dart';
import 'package:get_core/get_core.dart';
import 'package:get_instance/get_instance.dart';
import 'package:get_state_manager/get_state_manager.dart';
void main() {
Get.lazyPut<Controller2>(() => Controller2());
... ...
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:get/get.dart';
import 'package:get_core/get_core.dart';
import 'package:get_instance/get_instance.dart';
import 'package:get_state_manager/get_state_manager.dart';
void main() {
Get.lazyPut<Controller2>(() => Controller2());
... ...
import 'package:flutter_test/flutter_test.dart';
void main() {
test('adds one to input values', () {});
}
@TestOn('vm')
import 'dart:io';
import 'package:flutter_test/flutter_test.dart';
import 'package:get/get.dart';
import 'package:get_utils/get_utils.dart';
void main() {
test('Platform test', () {
... ...
@TestOn('browser')
import 'dart:io';
import 'package:flutter_test/flutter_test.dart';
import 'package:get/get.dart';
import 'package:get_utils/get_utils.dart';
void main() {
test('Platform test', () {
... ...