A dead-simple, yet extensible, C test framework.

Philosophy

Most test frameworks for C require a lot of boilerplate code to set up tests and test suites -- you need to create a main, then register new test suites, then register the tests within these suits, and finally call the right functions.

This gives the user great control, at the unfortunate cost of simplicity.

Criterion follows the KISS principle, while keeping the control the user would have with other frameworks:

  • Tests are automatically registered when declared.
  • A default entry point is provided, no need to declare a main unless you want to do special handling.
  • Test are isolated in their own process, crashes and signals can be reported and tested.
  • Progress and statistics can be followed in real time with report hooks.

Installation

$ git clone https://github.com/Snaipe/Criterion.git
$ cd Criterion
$ ./autogen.sh && ./configure && make && sudo make install

Given a test file named test.c, compile it with -lcriterion :

$ gcc -o test test.c -lcriterion

Samples

Sample tests can be found in thesample directory.

Q. What's wrong with other test frameworks?

A. I worked with CUnit and Check, and I must say that they do their job very well -- the only thing that bugs me is that setting up a test suite from scratch is a pain, it should really be simpler. Most (if not all) high-level languages have test frameworks with automatic test registration, but all the ones for C require you to set up a main, manually register suites, then tests. Criterion tries to fix these shortcomings.

Q. Where has this been tested?

A. Currently, on Linux 2.6.32 and Linux 3.15.7, although it should work on most *nix systems. More tests will be added on the build matrix.

Q. Will this work under Windows/MSVC?

A. Windows support with MinGW is coming, but MSVC is a bit of a lost cause for the C language. The project internally uses c99 features and gnu extensions, and MSVC is stuck at supporting c89.

Criterion - 一个简单可扩展的 C 语言测试框架的更多相关文章

  1. 将一个对象相同的属性(不区分大小写)赋值给一个新对象 DataTable的一个简单的扩展

    将一个对象相同的属性(不区分大小写)赋值给一个新对象   1 public static T Mapper<S, T>(S source) 2 { 3 T t = Activator.Cr ...

  2. 《maven实战》笔记(2)----一个简单maven项目的搭建,测试和打包

    参照<maven实战>在本地创建对应的基本项目helloworld,在本地完成后项目结构如下: 可以看到maven项目的骨架:src/main/java(javaz主代码)src/test ...

  3. 一个简单的NetCore项目:1 - 搭建框架,生成数据库

    1- 启动项目 安装.NETCORE SDK,教程在网上可以搜索的到,这里就不讲述了.简单粗暴的方式就是安装最新的VS2015. 2-搭建框架 2.1 打开VS新建一个项目,在弹出的新建项目对话框中, ...

  4. Python实现一个简单三层神经网络的搭建并测试

    python实现一个简单三层神经网络的搭建(有代码) 废话不多说了,直接步入正题,一个完整的神经网络一般由三层构成:输入层,隐藏层(可以有多层)和输出层.本文所构建的神经网络隐藏层只有一层.一个神经网 ...

  5. 一个简单但能考察C语言基础的题目

    请看题: #include<stdio.h> int a=1; int main(void) { int a=a; printf("a=d%\n",a); return ...

  6. DataTable的一个简单的扩展

    我们在调试代码的时候经常遇到DataTable的数据类型错误,这个类可以帮助我们很快查看DataTable的结构信息. /// <summary> /// DataTable扩展类 /// ...

  7. 一个简单的、面向对象的javascript基础框架

    如果以后公司再能让我独立做一套新的完整系统,那么我肯定会为这个系统再写一个前端框架,那么我到底该如何写这个框架呢? 在我以前的博客里我给大家展示了一个我自己写的框架,由于当时时间很紧张,做之前几乎没有 ...

  8. 使用react-native做一个简单的应用-04界面主框架

    欢迎界面搭建完毕,我们接下来需要做的就是搭建应用程序的主体框架啦.首先我们看一下首页的截图: 从图中看到,我将首页分为了三部分:用黑色矩形表示的头部,绿色表示的内容和红色表示的底部. 下面我们需要解决 ...

  9. 手写网站服务器~用Python手动实现一个简单的服务器,不借助任何框架在浏览器中输出任意内容

    写在前面的一些P话: 在公司网站开发中,我们往往借助于Flask.Django等网站开发框架去提高网站开发效率.那么在面试后端开发工程师的时候,面试官可能就会问到网站开发的底层原理是什么? 我们不止仅 ...

随机推荐

  1. Codeforces 158B:Taxi

    B. Taxi time limit per test 3 seconds memory limit per test 256 megabytes input standard input outpu ...

  2. 中南林业科技大学第十一届程序设计大赛-C:有趣的二进制

    链接:https://www.nowcoder.com/acm/contest/124/C来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 131072K,其他语言26214 ...

  3. Linux下定时切割Mongodb数据库日志并删除指定天数前的日志记录

    此为在网络上找来的,觉得很好! 实现目的: 对Mongodb数据库日志按天保存,并且只保留最近7天的日志记录. 具体操作: 使用Mongodb数据库自带的命令来切割日志 ps -def | grep ...

  4. 微信跳一跳,Python辅助自动跳程序

    一.说明 此代码借鉴一位大神提供在gitHub上的源码,已经做了简化合并处理,成功连上手机并运行后,可实现自动玩微信跳一跳游戏,刷个1000+的分数轻轻松松 github源码地址 https://gi ...

  5. odoo 数据库选择的随笔

    odoo 数据库选择的随笔 看到有人讨论 odoo 是否可以使用 SQL Server(MS SQL). 原来 odoo 使用的是 PostgreSQL,PostgreSQL 是很先进的关系性数据库, ...

  6. 冒泡排序算法-Python实现

    #-*- coding: UTF-8 -*- import numpy as np def BubbleSort(a): for i in xrange(0, a.size): for j in xr ...

  7. 【linux】linux文件属性权限的介绍

    众所周知,root的信息存在/etc/passwd下,个人密码存在/etc/shadow下,所有组名存在/etc/group下,因此这三个文件十分重要. 在linux系统下,我们可以通过"l ...

  8. Oracle中的一连接语句

    首先构建场景 相应表中数据如下: SELECT * FROM EMPLOYEE: SELECT * FROM DEPTINFO; 连接方式: 1. , SELECT E.EMPNAME, D.DEPN ...

  9. ASP.NET 获得当前网页名字

    Code string currentFilePath = HttpContext.Current.Request.FilePath; string CurrentPageName = current ...

  10. web deploy 部署到远程服务器(win server 2008 r2) 遇到的问题。。。。

    和他遇到的情况一样,最后也解决了 http://www.cnblogs.com/brucejia/archive/2012/07/30/2615416.html 安装的前提是先看下这里: http:/ ...