Logo: Relish

  1. Sign in

Project: Weyland 0.1.0

Tests

You can't build great software without tests. You just can't. Even if your
testing is automated you still are testing your software. Weyland aims to
make testing easier.

Tests in Weyland are defined like any other task with one caveat, they have
the test_for key set in their definition. The value of this key tells
Weyland what the task is meant to verify.

For example, say we have a C library that we're developing. To test this
library we have a simple program which excercises the various functions
of this library and then exits with either a 0 indicating success, or a
1 indicating that the test failed. In Weyland we would define this
using a build which looks something like:

Scenarios
C Static Library with a C Program test
Given
a file named "Weylandfile" with:
require 'weyland/c'

Weyland::package do |pkg|
	pkg.name = 'adder'

	pkg.c_staticlib 'adder', sources: [ 'src/add.c' ], include_dirs: ['include'], exports: [:include_dirs]

	pkg.c_program 'adder_test', sources: ['test/adder.c'], is_test_for: 'adder'
end 
And
a file named "include/adder/add.h" with:
int add(int a, int b);
And
a file named "src/add.c" with:
#include "adder/add.h"

int add(int a, int b) {
	return a + b;
}
And
a file named "test/adder.c" with:
#include "adder/add.h"

int main(int argc, char** argv) {
	if (add(1, 2) != 4) {
		return 1;
	}

	return 0;
}
When
I run weyland test
Then
the exit status should be 1
And
the output should contain:
TEST       adder      FAIL

Last published over 5 years ago by smkell.