You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
samples/testing_app/test/models/favorites_test.dart

43 lines
1.2 KiB

// Copyright 2020 The Flutter team. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:math';
import 'package:test/test.dart';
import 'package:testing_app/models/favorites.dart';
void main() {
group('Testing App Provider Tests', () {
// Create an object of the provider.
var favorites = Favorites();
test('A new item should be added', () {
// Generate a random number.
var number = Random().nextInt(50);
// Add the number to the list.
favorites.add(number);
// Verify if the number was inserted.
expect(favorites.items.contains(number), true);
});
test('An item should be removed', () {
// Generate a random number.
var number = Random().nextInt(50);
// Add the number to the list.
favorites.add(number);
// Verify if the number was inserted.
expect(favorites.items.contains(number), true);
// Remove the number from the list.
favorites.remove(number);
// Verify if the number was removed successfully.
expect(favorites.items.contains(number), false);
});
});
}