test('2 multiply 3 is equal to 6', (int a, int b) {
// Arrange
const a = 2;
const b = 3;
// Act
final answer = multiply(a, b);
// Assert
expect(answer, 6);
});
Created
November 11, 2023 05:47
-
-
Save alifgiant/502c8cb4441c11590d8d7729d64068e4 to your computer and use it in GitHub Desktop.
Unit Test Correctness vs Coverage, mana yang lebih penting?
test('a multiply b is equal to a * b', (int a, int b) {
// Arrange
const a = faker.datatype.number();
const b = faker.datatype.number();
// Act
final answer = multiply(a, b);
// Assert
expect(answer, a * b);
});
test('multiply is correct', (int a, int b) {
// Arrange
const a = 2;
const b = 3;
// Act
final answer = multiply(a, b);
// Assert
expect(a, greaterThan(0));
});
int multiply (int a, int b) {
return 6;
}
int multiply (int a, int b) {
return a * b;
}
test('2 multiply 3 is equal to 6', (int a, int b) {
// Arrange
const a = 2;
const b = 3;
// Act
final answer = multiply(a, b);
// Assert
expect(answer, 6);
});
test('2 multiply -3 is equal to -6', (int a, int b) {
// Arrange
const a = 2;
const b = -3;
// Act
final answer = multiply(a, b);
// Assert
expect(answer, -6);
});
test('a and b postive integer ...',(){..});
test('a and b negative integer ...',(){..});
test('a is positive and b is negative integer ...',(){..});
test('a is negative and b is positve integer ...',(){..});
test('a and b is 0 ...',(){..});
test('a or b is 0 ...',(){..});
test('a and b is 1 ...',(){..});
test('a or b is 1 ...',(){..});
...
int multiply (int a, int b) {
int sum = 0
fot (int i = 0; i < b; i++) {
sum += a;
}
return sum;
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment