Skip to content

buiquanghuy23103/Unity

 
 

Repository files navigation

Test repo for Hivers

What this repo about?

This repo is a fork of the Unity Test Project, one of the main projects of ThrowTheSwitch.org.

Everyone can add tests to test_libft/test directory of this repo. Each test file will be compiled to an executable named test_yourlogin.out in targets directory and run separately. The test depends on two symbolic links libft.h and libft.a which points to your header file and static library, meaning that you can put this repo outside of your workspace and run independently.

Documentation

The docs directory contains a "Getting started guide" and much more tips about using Unity.

How to run the test

  1. Go to test_libft
  2. Create symbolic link libft.a and libft.h to your static library and header respectively.
  3. Type make -s and hit Enter. The option -s will prevent make from printing all the commands it runs.

How to write a test

  1. Go to test_libft/test
  2. Create a C file whose name follows the format test_yourLogin.c. By doing this, if someone want to contact you regarding your test file, they know how to reach you. Below is an example of a test file:
#include "libft.h"
#include "unity.h"

void setUp(void)
{
}

void tearDown(void)
{
}

void test_strlen(void)
{
	TEST_ASSERT_EQUAL(3, ft_strlen("abc"));
}

Please note that even though setup() and tearDown() are empty, you should not remove it. Otherwise, the test will not run. Please refer to the documentation for more information.

Name of each test function needs to start with test. Otherwise, the test function will not be recognized by the test runner, and thus will not run.

Recommendation

It is recommended that each Hiver has his/her own test file and don't modify the others to avoid conflicts. You can provide feedbacks to others' tests by leaving a comment on GitHub and don't forget to enable GitHub notification.

If you want to split your test code into multiple files, feel free to do it. However, please remember to put your login in the test file.

How to contribute to the project

If you want to make your test files visible on this GitHub, please follow this instruction on how to contribute to a GitHub project

About

Simple Unit Testing for C

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C 81.5%
  • Ruby 13.5%
  • Makefile 2.0%
  • Python 1.2%
  • Shell 0.9%
  • CMake 0.7%
  • Other 0.2%