junit

Running JUnit4 Test classes in specified order

馋奶兔 提交于 2020-02-26 18:24:52
问题 I've written a number of tests, divided not only into separate classes but, depending on what area of my application they're testing, into separate sub-packages. So, my package structure looks a bit like this: my.package.tests my.package.tests.four my.package.tests.one my.package.tests.three my.package.tests.two In the my.package.tests package I have a parent class that all tests in the sub-packages one through four extend. Now, I would like to choose the order in which the tests are run; not

Running JUnit4 Test classes in specified order

浪尽此生 提交于 2020-02-26 18:24:50
问题 I've written a number of tests, divided not only into separate classes but, depending on what area of my application they're testing, into separate sub-packages. So, my package structure looks a bit like this: my.package.tests my.package.tests.four my.package.tests.one my.package.tests.three my.package.tests.two In the my.package.tests package I have a parent class that all tests in the sub-packages one through four extend. Now, I would like to choose the order in which the tests are run; not

Running JUnit4 Test classes in specified order

五迷三道 提交于 2020-02-26 18:23:46
问题 I've written a number of tests, divided not only into separate classes but, depending on what area of my application they're testing, into separate sub-packages. So, my package structure looks a bit like this: my.package.tests my.package.tests.four my.package.tests.one my.package.tests.three my.package.tests.two In the my.package.tests package I have a parent class that all tests in the sub-packages one through four extend. Now, I would like to choose the order in which the tests are run; not

实战Arch Unit

帅比萌擦擦* 提交于 2020-02-26 16:12:59
在以前的文章中介绍了通过 [《实战PMD》]( https://zhuanlan.zhihu.com/p/105585075 )、[《实战Checkstyle》]( https://zhuanlan.zhihu.com/p/105583516 )在代码级守护我们的代码,比通过[《实战Jacoco》]( https://zhuanlan.zhihu.com/p/105581725 )来了解当前项目的测试覆盖情况。通过得到数据了解我们的项目质量,进行定向的改进。 使用这些简单方面的自动化工具比凭空猜想或者全靠人力来接发现代码上的问题,效率高多了。 这篇文章将聚焦在`Arch Unit`上,`Arch Unit`能通过为我们提供架构的守护。 1. 开发前的准备 2. 项目分层检测 3. 循环依赖检测(同一个package下,不同package下的循环依赖) 4. Package依赖检测 5. Package和Class的包含关系检测 6. 忽略某些违规行为的三种凡是 7. 如何组织Arch Unit的测试 先来看一下Arch Unit的相关功能介绍。 这些功能很好,但是要是面面俱到,那么维护、查看规则也是一件麻烦事,所以针对项目情况,有选择定制,才能更好的展现器价值。 通过自己坐在项目的情况,可以通过金字塔来罗列:哪些行为做了价值大,哪些事情做了价值小。 --- ### 1,开发前的准备

junit.framework.AssertionFailedError: No tests found in **问题的解决

白昼怎懂夜的黑 提交于 2020-02-26 12:13:14
今天在跟B站学习aop的过程中,想要编写测试类来测试自己的aop到底成不成功,于是编写测试类如下: import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import com.itheima.service.IAccountService; import junit.framework.TestCase; public class testAccountService extends TestCase { ApplicationContext ac = new ClassPathXmlApplicationContext("bean.xml"); IAccountService as = (IAccountService)ac.getBean("accountService"); public void transferTest(){ as.transfer("bbb", "aaa", 100); } } 得到的报错结果如下: junit.framework.AssertionFailedError: No tests found in com.itheima.test

程序员需要了解依赖冲突的原因以及解决方案

♀尐吖头ヾ 提交于 2020-02-26 07:35:16
0x00. 前言 依赖冲突是日常开发中经常碰到的过程,如果运气好,并不会有什么问题。偏偏小黑哥有点背,碰到好几次生产问题,排查一整晚,最后发现却是依赖冲突的引起的问题。 没碰到过这个问题同学可能没什么感觉,小黑哥举两个最近碰到例子,让大家感受一些。 例子 1: 我们公司有个古老的业务基础包 A。B,C 业务依赖这个包。某个团队拷贝 A 的部分代码进行重构, 类名与路径完全一样 ,然后重新打包成 D 发布。 一次业务改动,B 业务也引入了 D 包,测试环境运行的时候,一切 OK,但是在生产运行时,却抛出 NoSuchMethodError 。 问题原因在于 B 业务依赖 A,D。而 A,D 存在两个同包同名类,运行的时候,具体加载谁,不同环境还真不一样。 例子 2: A 业务使用 Dubbo 进行 RPC 调用, Dubbo 需要依赖 javassist 。当前依赖关系为: A------->Dubbo------->javassist-3.18.1.GA 某次改动中引入另外一个第三方开源包,其依赖 javassist-3.15.0-GA 。生产发布的时候,将 javassist-3.15.0-GA 打包到应用中,由于生产环节为 JDK1.8,从而导致运行直接失败。 除了上述问题,依赖冲突还可能导致应用抛出 ClassNotFoundException ,

面向Java开发人员的十种测试框架库

泪湿孤枕 提交于 2020-02-26 03:14:17
【51CTO.com快译】引言:您想提升自己的自动化测试能力吗?这里为您提供了10款优秀的测试框架库,以及它们的***用例。 测试能力可谓是鉴别专业开发人员与业余新手的利器。它不仅体现在是否能遵循TDD(Test-Driven Development,测试驱动开发)、BDD(Behavior-Driven Development,行为驱动开发)或其他任何测试方法,而且反映了您是否具有编写出能够自动测试软件代码的能力。 如今,许多Java开发人员主要通过使用持续集成的工具(如Jenkins或TeamCity),编写出会在构建时就能自动运行的各种单元与集成测试程序。 如果在您的身边还有人对于“程序员为何应该关注自动化测试”存有疑问的话,那么可以告诉他:随着DevOps的出现和对它认识的加深,业界对于自动化测试的重要性也在呈指数式增长中。 对于一般公司而言,通常会更倾慕那些擅长编写单元测试的程序员们。因为他们熟悉各种单元测试的框架库与工具,例如JUnit,Selenium,REST-Assured,Spock框架等。 作为一名Java开发人员,我们经常会涉及到一些截然不同的领域,例如:编写核心的Java代码、创建JSP页面、编写REST APIs、有时甚至会为了自动化的构建而创建一些Groovy脚本。这也是为什么我们还需要了解如何运用不同的工具来进行自动化测试的原因。 比如说

Spring框架-第二篇

时光怂恿深爱的人放手 提交于 2020-02-26 02:23:09
第一章:Spring的IOC实现CRUD 1.1-需求和技术要求 需求:实现账户的 CRUD 操作 技术: 使用 spring 的 IoC 实现对象的管理 使用 dbutils作为持久层解决方案 使用 c3p0 数据源 1.2-环境搭建 1.2.1-Maven工程导入依赖 <dependencies> <!--junit--> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.11</version> <scope>test</scope> </dependency> <!--dbUtils--> <dependency> <groupId>commons-dbutils</groupId> <artifactId>commons-dbutils</artifactId> <version>1.4</version> </dependency> <!--c3p0--> <dependency> <groupId>com.mchange</groupId> <artifactId>c3p0</artifactId> <version>0.9.5.2</version> </dependency> <!--spring--> <dependency> <groupId>org

数据库连接异常

旧城冷巷雨未停 提交于 2020-02-26 02:16:38
连接数据库时经常出现的异常就是java.lang.ClassNotFoundException: com.mysql.jdbc.Driver。所以今天我结合自己的经验给大家总结一下,碰到这类的异常要如何处理,首先给大家分享一下我在用MyBatis逆向生成时碰到到的这个异常。 异常信息如下 java.lang.RuntimeException: Exception getting JDBC Driver at org.mybatis.generator.internal.JDBCConnectionFactory.getDriver(JDBCConnectionFactory.java:100) at org.mybatis.generator.internal.JDBCConnectionFactory.getConnection(JDBCConnectionFactory.java:70) at org.mybatis.generator.config.Context.getConnection(Context.java:753) at org.mybatis.generator.config.Context.introspectTables(Context.java:631) at org.mybatis.generator.api.MyBatisGenerator

Intro to Spring Boot Starters

左心房为你撑大大i 提交于 2020-02-25 22:12:44
1. Overview Dependency management is a critical aspects of any complex project. And doing this manually is less than ideal; the more time you spent on it the less time you have on the other important aspects of the project. Spring Boot starters were built to address exactly this problem. Starter POMs are a set of convenient dependency descriptors that you can include in your application. You get a one-stop-shop for all the Spring and related technology that you need, without having to hunt through sample code and copy-paste loads of dependency descriptors. We have more than 30 Boot starters