Skip to main content

test

Basic Setup

Tests are written just like how you'd write outside of Codewars.

The solution belongs to a package named solution. So it can be imported from package:solution/solution.dart and the optional preloaded code provided by the kata author can be imported from package:solution/preloaded.dart.

Solution

int add(int a, int b) {
  return a + b;
}
int add(int a, int b) {
  return a + b;
}

Tests

import "package:test/test.dart";
import "package:solution/solution.dart";

void main() {
  group("adder", () {
    test("adds two numbers", () {
      expect(add(1, 2), equals(3));
    });
  });
}
import "package:test/test.dart";
import "package:solution/solution.dart";

void main() {
  group("adder", () {
    test("adds two numbers", () {
      expect(add(1, 2), equals(3));
    });
  });
}

See test's documentation for how to write tests.