Skip to content

Latest commit

 

History

History
53 lines (41 loc) · 1.32 KB

dart_test.md

File metadata and controls

53 lines (41 loc) · 1.32 KB

Dart - Bootstrapping Test

Note: This guide assumes you have Dart SDK and stagehand installed.

  1. Create a new project structure for the code.

    (Assuming the project is named new_kata)

    mkdir new_kata
    cd new_kata
    stagehand package-simple
    pub get
  2. Modify the generated implementation file (new_kata\test\new_kata_test.dart) with the following content:

    import 'package:new_kata/new_kata.dart';
    import 'package:test/test.dart';
    
    void main() {
        group('Coding Dojo Test Suite', () {
            KataLib library;
    
            setUp(() {
                library = KataLib();
            });
    
            test('Simple Addition Test', () {
                expect(library.add(1, 2), 3);
            });
        });
    }
  3. Modify the generated implementation file (new_kata\lib\src\new_kata_base.dart) with the following content:

    class KataLib {
        int add(int x, int y) => x + y;
    }
  4. Run the test.

    pub run test

    You should see something like this:

    00:04 +1: All tests passed!

Checkout the Dart Language Tour to know more about the language.