junit

Why Log.d() print nothing when running Android Local Unit Test?

試著忘記壹切 提交于 2020-02-21 07:48:23
问题 I'm trying to print something when running Android Local Unit Test , but nothing's happening. What's the matter? How can I fix it? I consulted some documents on http://developer.android.com, found that Android Local Unit Test just run on my machine's JVM, the android.jar file that is used to run unit tests does not contain any actual code, so Log.d() print nothing. If i wanna print log, how can i do? Here is my code, FeedbackModelTest.java located in src/test/main directory. package com

I need to mock a RabbitMQ in my unit Test

和自甴很熟 提交于 2020-02-19 14:17:52
问题 I am using a RabbitMQ in my project. I have in my consumer the code of the client part of rabbitMQ and the connection need a tls1.1 to connect with the real MQ. I want to test this code in my JUnit test and to mock the message delivery to my consumer. I see in google several examples with different tools how camel rabbit or activeMQ but this tools works with amqp 1.0 and rabbitMQ only works in amqp 0.9 . Someone had this problem? Thanks! UPDATE This is the code to testing to receive a json

I need to mock a RabbitMQ in my unit Test

六月ゝ 毕业季﹏ 提交于 2020-02-19 14:16:50
问题 I am using a RabbitMQ in my project. I have in my consumer the code of the client part of rabbitMQ and the connection need a tls1.1 to connect with the real MQ. I want to test this code in my JUnit test and to mock the message delivery to my consumer. I see in google several examples with different tools how camel rabbit or activeMQ but this tools works with amqp 1.0 and rabbitMQ only works in amqp 0.9 . Someone had this problem? Thanks! UPDATE This is the code to testing to receive a json

I need to mock a RabbitMQ in my unit Test

江枫思渺然 提交于 2020-02-19 14:15:19
问题 I am using a RabbitMQ in my project. I have in my consumer the code of the client part of rabbitMQ and the connection need a tls1.1 to connect with the real MQ. I want to test this code in my JUnit test and to mock the message delivery to my consumer. I see in google several examples with different tools how camel rabbit or activeMQ but this tools works with amqp 1.0 and rabbitMQ only works in amqp 0.9 . Someone had this problem? Thanks! UPDATE This is the code to testing to receive a json

junit testing - assertEquals for exception

爷,独闯天下 提交于 2020-02-18 13:55:50
问题 How can I use assertEquals to see if the exception message is correct? The test passes but I don't know if it hits the correct error or not. The test I am running. @Test public void testTC3() { try { assertEquals("Legal Values: Package Type must be P or R", Shipping.shippingCost('P', -5)); } catch (Exception e) { } } The method being tested. public static int shippingCost(char packageType, int weight) throws Exception { String e1 = "Legal Values: Package Type must be P or R"; String e2 =

Maven 09.依赖传递

北城余情 提交于 2020-02-17 14:27:11
Maven是用来管理项目的,按道理是可以实现一个项目引用另一个项目。如果被引用的项目本身就引用了jar包呢?例如junit jar包呢? 例子: HelloWorldTime -->HelloWorld2 ---->Test 还没有修改pom.xml之前的HelloWorldTime jar包情况 写入对HelloWorld2项目的依赖 同时HelloWorld2中的pom.xml中阐述的对junit的依赖关系,这里的对junit的有效性范围是test 更新update maven后:HelloWorldTime的jar包情况没有发生改变 把HelloWorld2中的对junit的依赖改成compile后: 结果:HelloWorldTime的jar包情况出现了junit 依赖的原则: 01.就近。 maven会选择3.8 02.相同的路径的话,谁在前面谁优先。(一个pom.xml文件中是不允许依赖两个相同的jar包,即使是版本号不同) 这个时候,在HelloWorldTime的pom.xml文件中,对那个项目的依赖先写,那个jar包就会被下载到HelloWorldTime中去。 来源: CSDN 作者: qq_38757863 链接: https://blog.csdn.net/qq_38757863/article/details/104354027

单元测试不止 Junit

断了今生、忘了曾经 提交于 2020-02-17 09:03:52
一、前言 在前面的章节我们介绍过 Junit 的使用,也了解过 spring-test,今天我们来了解一个新玩意 – mock 测试。这里仅仅做一个入门,对返回视图和返回 Json 数据的方法进行测试演示,不会把所有的方法都介绍到,具体文档详见链接:Mock Test,本章节主要讲解以下两部分内容: 1、Mock 测试简介 2、测试用例演示 二、Mock 测试简介 1、什么是 mock 测试 在测试过程中,对于某些不容易构造或者不容易获取的对象,用一个 虚拟的对象 来创建以便测试的测试方法,就是 mock 测试 在测试过程中,对于某些不容易构造或者不容易获取的对象,用一个 虚拟的对象 来创建以便测试的测试方法,就是* mock 测试*。 虚拟的对象就是 mock 对象。 mock 对象就是真实对象在调试期间的代替品。 2、为什么使用 mock 测试 避免开发模块之间的耦合 轻量、简单、灵活 3、MockMVC 介绍 基于 RESTful 风格的 SpringMVC 的测试,我们可以测试完整的 Spring MVC 流程,即从 URL 请求到控制器处理,再到视图渲染都可以测试。 1)MockMvcBuilder MockMvcBuilder 是用来构造 MockMvc 的构造器,其主要有两个实现:StandaloneMockMvcBuilder 和

How to run all tests in a particular package with Maven?

走远了吗. 提交于 2020-02-16 14:02:36
问题 I can find in the Maven docs where it shows how to run: A single test All tests in a single test class All tests in classes matching a particular pattern But how to run all the tests in a package? Is this possible? I would prefer solutions that don't require modifying the pom.xml or code. 回答1: You could use a pattern as well, for example mvn '-Dtest=de.mypackage.*Test' test runs all tests in classes from package de.mypackage ending on *Test . [update 2017/12/18]: Since this became the

How to run all tests in a particular package with Maven?

安稳与你 提交于 2020-02-16 14:00:14
问题 I can find in the Maven docs where it shows how to run: A single test All tests in a single test class All tests in classes matching a particular pattern But how to run all the tests in a package? Is this possible? I would prefer solutions that don't require modifying the pom.xml or code. 回答1: You could use a pattern as well, for example mvn '-Dtest=de.mypackage.*Test' test runs all tests in classes from package de.mypackage ending on *Test . [update 2017/12/18]: Since this became the

Failed to read candidate component class错误分析

此生再无相见时 提交于 2020-02-15 20:32:43
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [D:\MyWorkspace\spring_mybatis1222\out\test\spring_mybatis1222\cn\itcast\ssm\mapper\UserMapperTest.class]; nested exception is java.lang.IllegalArgumentException at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:281) at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:242) at org.mybatis.spring.mapper