Git Product home page Git Product logo

perf-unit's Introduction

perf-unit

项目概述

项目的设计**和结构主要参考杭州有赞公司的这篇文章 有赞单元测试实践,基于junit4进行二次开发。

数据库层

有赞单云测试实践 如上图,perf-unit框架的将单元测试数据库统一成springtest+dbunit+h2的结构,数据源文件支持xml/csv/excel三种格式,通过@SecTest注解引入。perf-unit的主要创新点是引入了动态数据源,让有依赖数据库层的测试用例也支持并发执行。

 @Test
 @SecTest(enablePrepare=true,
   prepareDateType = PrepareDataType.XML2DB,
   prepareDateConfig = {"sampleData.xml"},
   enableCheck = true,
   checkConfigFiles = {"CheckConfigFile.json"})
 public void testXml() throws Exception {
  List<Person> personList = this.personService.find("hil");
  Assert.assertEquals(1, personList.size());
 }

并发设计

基于spring的项目在批量执行多个测试用例场景时,依赖springtest框架进行测试,单线程测试用例跑的比较慢。 junit框架默认未提供并发注解支持,junit有很多第三方扩展插件支持并发测试,其中idea的plugin商店并发扩展插件junit4-parallel-runner。testng框架原生支持并发,详见testng并发。 perf-unit也提供了SecParallelSpringRunner,SecParallelSuite,支持最小到method级别的并发。

测试用例

测试用例见perf-unit-test项目,目前基于springboot2.x测试通过,已提供完整的jpa和mybatis测试用例。 在使用perf-unit过程中,需要做的额外工作将我们日常的mysql数据库的建表sql转换成h2支持的格式,然后通过dbunit提供的工具类连mysql导出数据到对应的xml/excel/csv文件即可使用。

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.