docs
单元测试

单元测试

MLT 的单元测试套件位于源码树中的 src/tests。

它使用 !QtTestLib 框架。

在源码树内构建时使用它的方法:

  1. 构建 mlt
  2. source setenv
  3. export PKG_CONFIG_PATH=”<BUILD_DIR>/lib/pkgconfig $PKG_CONFIG_PATH”
    (<BUILD_DIR> 需要改成 第 1 步的目标目录)
  4. cd src/tests
  5. qmake -r tests.pro
  6. make check

在影子(shadow)构建目录中使用它的方法:

  1. 构建 mlt
  2. source setenv
  3. export PKG_CONFIG_PATH=”<BUILD_DIR>/lib/pkgconfig $PKG_CONFIG_PATH”
    (<BUILD_DIR> 需要改成 第 1 步的目标目录)
  4. cd src
  5. mkdir tests-build
  6. cd tests-build
  7. qmake -r ../tests/tests.pro
  8. make check 单独的 “make” 会构建测试,“make check” 会在保证 构建是最新的前提下运行它们。

测试套件中有多个可执行文件,每一个都会为失败的测试数量返回一个 > 0 的 退出码。

截至 2013-05-01 的输出示例:

ddennedy-macbook:tests-build ddennedy$ make check
cd test_properties/ && make -f Makefile check
./test_properties
********* Start testing of TestProperties *********
Config: Using QTest library 4.8.4, Qt 4.8.4
PASS   : TestProperties::initTestCase()
PASS   : TestProperties::InstantiationIsAReference()
PASS   : TestProperties::CopyAddsReference()
PASS   : TestProperties::DestructionRemovesReference()
PASS   : TestProperties::cleanupTestCase()
Totals: 5 passed, 0 failed, 0 skipped
********* Finished testing of TestProperties *********
cd test_repository/ && make -f Makefile check
./test_repository
********* Start testing of TestRepository *********
Config: Using QTest library 4.8.4, Qt 4.8.4
PASS   : TestRepository::initTestCase()
PASS   : TestRepository::ThereAreProducers()
PASS   : TestRepository::ThereAreConsumers()
PASS   : TestRepository::cleanupTestCase()
Totals: 4 passed, 0 failed, 0 skipped
********* Finished testing of TestRepository *********