Giter Club home page Giter Club logo

prjwithci's Introduction

一、项目目录架构

  • 目录如下:

3rd 存放第三方源代码项目(gtest)

build 项目使用外部构建,整个项目的构建目录

ci 项目产生的CI服务器需要的数据

include 存放接口文件或binary库的头文件

lib binary库

src 项目的源代码目录

ut 项目的单元测试目录

st 项目的系统测试目录

script 项目的脚本目录

rpm 项目发布

doc 项目文档

二、CMake相关

  • 因为赖,不想些更多的Makefile
  • 从写Makefile改成写CMakeLists.txt
  • 看一段CMakeLists.txt吧。

三、GCOV相关

  • GCOV 是 GCC Coverage
  • 是一个测试代码覆盖率的工具
  • 也是一个命令行方式的控制台程序
  • 添加上-fprofile-arcs -ftest-coverage编译选项就能启用
  • 编译后生成*.gcno文件,执行该代码片段生成*.gcna
  • 然后执行gcov就能生成*.gcov覆盖率报告

四、GTEST相关

  • GTest是google出品的单元测试框架!
  • UT具有以下几个基本概念:

断言 ->测试 ->测试用例 ->测试套件(整个单元测试)

  • 断言gtest提供以下断言宏(检查宏):
//在gtest中断言是一系列 EXPECT_* 和 ASSERT_* 的检查宏。
EXPECT_*(); // 失败时,案例继续往下执行。
ASSERT_*(); // 失败时,直接在当前函数中返回。
  • 测试测试由一系列断言来检查功能代码。
  • 测试用例根据功能代码将一系列测试组织起来,这就形成了测试用例。
  • 测试套件共享某个固件环境的所有测试合称为一个“测试套件”。
// 以下代码对应了断言、测试、测试用例等几个概念
#include "gtest/gtest.h"

int returnOne() {
    return 1;
}

int returnTwo() {
    return 2;
}

TEST(test_case_name, test_name) {
    //... test body ...
    ASSERT_EQ(1, returnOne());
    EXPECT_EQ(2, returnTwo());
}

GTEST_API_ int main(int argc, char **argv) {
    testing::InitGoogleTest(&argc, argv);
    return RUN_ALL_TESTS();
}
  • 执行演示

coding show!

  • GMOCK

五、CI相关

  • 名持续集成
  • 为项目提供质量保证等配套功能
  • 大体功能如下(不限于)

代码静态检查 单元测试 系统测试 代码覆盖率

日构建 版本发布 构建report

  • CI服务器使用及演示

六、总结&MORE

  • 更多的工作量
  • 避免新增代码对已有代码的影响
  • 更好的工作交接
  • ST框架需要集成
  • 静态检查是否必要

七、使用

需要配合jenkins和git使用才能发挥PrjWithCi最佳实践。

  • 执行sh build.sh help获取帮助
  • 执行sh build.sh ci构建具有包含UT功能的CI
  • 执行sh build.sh release构建发布版本

prjwithci's People

Contributors

yueliangwen avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.