quick_test 0.0.7 copy "quick_test: ^0.0.7" to clipboard
quick_test: ^0.0.7 copied to clipboard

Quick is a behavior-driven development framework for Flutter. Inspired by Quick (swift).

example/main.dart

import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:quick_test/quick_test.dart';
import 'package:quick_test/quick_widget_test.dart' as widget;

enum BrandType { unknown, audi, bmw, f1 }

abstract class Driveable {
  void drive();

  void stop();
}

class Vehicle implements Driveable {
  int numberOfWheels = 1;

  BrandType brand = BrandType.unknown;

  void drive() {
    print("I am driving");
  }

  void stop() {
    print("I am stopped");
  }
}

class Car extends Vehicle {
  @override
  int numberOfWheels = 4;
}

class AWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Directionality(
      textDirection: TextDirection.ltr,
      child: Text("it is me"),
    );
  }
}

/// TEST
void main() {
  describe("a vehicle", () {
    // Context without a vehicle type
    context("after being properly initialized", () {
      final vehicle = Vehicle();

      it("should have a brand", () {
        expect(vehicle.brand, isNotNull);
      });
    });

    // Context using vehicle type
    context("after being properly initialized using vehicle type", () {
      final expectedCarWheels = 4;
      final vehicle = Car();

      it("should have a brand", () {
        expect(vehicle.brand, isNotNull);
      });

      it("should have number of wheels constrained to its type", () {
        expect(vehicle.numberOfWheels, expectedCarWheels);
      });
    });
  });

  widget.describe("a Widget", () {
    widget.beforeEach((tester) async {
      await tester.pumpWidget(AWidget());
    });

    widget.it("contains 'it is me' text", (tester) async {
      expect(find.text("it is me"), findsOneWidget);
    });
  });
}
1
likes
130
pub points
6%
popularity

Publisher

unverified uploader

Quick is a behavior-driven development framework for Flutter. Inspired by Quick (swift).

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter, flutter_test, meta, mockito

More

Packages that depend on quick_test