junit

how to pass date via url parameter - junit test with dates

我的梦境 提交于 2020-01-26 03:57:08
问题 I want to pass my Date via parameter, and I dont exactly know how to do it. I have tried EncodeUrl.encode(), but it didnt work (it is possible that I did something wrong) @Test public void getUsageCountersParam2Test() throws Exception { Date date = new Date(2017, 06, 23, 12, 39, 20); MvcResult result = mockMvc.perform(get(getUri("/usages?apiConsumerId=[1,2]&serviceId=1&dateFrom=" + date)).contentType(MediaType.APPLICATION_JSON)).andExpect(status().isOk()).andReturn(); ObjectMapper mapper =

Why the arquillian gives me that : Could not read active container configuration?

和自甴很熟 提交于 2020-01-26 02:06:50
问题 I try to integrate the arquillian solution into my maven EJB project which contains juste the EJBs which I uses in other separate projects. I use Jboss EAP6. So i have make it as the following : I made the arquillian.xml into ejbModule/src/test/resources/: <container qualifier="jboss" default="true"> <configuration> <property name="jbossHome">D:\jbdevstudio\jboss-eap-6.2</property> </configuration> </container> in the pom of my project i added the following dependencies: <dependency> <groupId

Spring整合junit

↘锁芯ラ 提交于 2020-01-25 17:45:05
应用程序的入口:main方法 junit单元测试中没有main方法也能执行 junit集合了一个main方法 该方法就会判断当前测试类中有哪些方法有@Test方法 junit就会让有@Test的方法执行 junit不会管我们有没有采用spring框架 在执行测试方法时,junit根本不知道我们是不是采用了spring框架 所以也就不会为我们读取配置文件/配置类 创建spring核心容器 由以上三点可以知道: 当测试方法执行时,没有Ioc容器,就算写了@Autowired注解,也无法实现注入 使用Junit单元测试,测试我们的配置 Spring整合junit的配置 导入spring的整合jubit的jar包 使用junit提供的注解把原有的main方法替换下来,替换成spring提供的 @Runwith 告知spring的运行器,spring和ioc创建是基于xml还是注解,并且说明位置 @ContextConfiguration locations : 指定xml文件的位置,加上classpath关键字,表示在类路径下 classes : 指定注解所在的位置 举例子: package com.xuefei.ui; import com.xuefei.domain.Account; import com.xuefei.service.IAccountService; import

使用 JUnit 报错 java.lang.Exception: No runnable methods

梦想的初衷 提交于 2020-01-25 09:31:13
错误详情如下: java.lang.Exception: No runnable methods at org.junit.runners.BlockJUnit4ClassRunner.validateInstanceMethods(BlockJUnit4ClassRunner.java:169) at org.junit.runners.BlockJUnit4ClassRunner.collectInitializationErrors(BlockJUnit4ClassRunner.java:104) at org.junit.runners.ParentRunner.validate(ParentRunner.java:355) at org.junit.runners.ParentRunner.<init>(ParentRunner.java:76) at org.junit.runners.BlockJUnit4ClassRunner.<init>(BlockJUnit4ClassRunner.java:57) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.<init>(SpringJUnit4ClassRunner.java:104) at sun.reflect

java【selenium】拖拽页面元素

独自空忆成欢 提交于 2020-01-25 08:41:06
import static org . junit . jupiter . api . Assertions . * ; import java . util . concurrent . TimeUnit ; import org . junit . jupiter . api . AfterEach ; import org . junit . jupiter . api . BeforeEach ; import org . junit . jupiter . api . Test ; import org . openqa . selenium . By ; import org . openqa . selenium . WebDriver ; import org . openqa . selenium . WebElement ; import org . openqa . selenium . chrome . ChromeDriver ; import org . openqa . selenium . interactions . Actions ; import Test1 . ChromeDriveDemo ; class DragAnddropElements { /* * 拖拽页面的元素 */ WebDriver driver ; String

No ParameterResolver registered for parameter [io.vertx.ext.unit.TestContext arg0]

我的梦境 提交于 2020-01-25 08:33:05
问题 I am trying to write a test case for vertx related stuff. Here is my code import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import io.vertx.core.Vertx; import io.vertx.core.http.HttpClient; import io.vertx.core.http.HttpServer; import io.vertx.ext.unit.Async; import io.vertx.ext.unit.TestContext; import io.vertx.ext.unit.junit.VertxUnitRunner; @RunWith(VertxUnitRunner.class) public class

WedDriverException : java.util.HashMap cannot be cast to java.lang.String when initializing RemoteWebDriver

若如初见. 提交于 2020-01-25 04:49:16
问题 I am trying to run Junit tests in parllel ,did a grid setup with 3 nodes , while executing the test got an exception org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. My understanding is There is nothing to do with Firefox and selenium version , I believe the exception is due to lock issued by the firefox for an webdriver instance which is not released within 45000 ms which throws an timeout exception for other webdriver

Junit : how to make conditional tests?

社会主义新天地 提交于 2020-01-25 04:47:06
问题 I'm trying to write conditional tests with JUnit. I need to test the persistence of objects and if those tests pass, test access via HTTP methods (in order to develop a REST Web Service). For this moment my solution looks like this : public class ApplicationTest { @Test public void testSuite() { final Request requestStatutTest = Request.method(this.getClass(), "insertStatutTest"); final Result resStatutTest = new JUnitCore().run(requestStatutTest); if (resStatutTest.wasSuccessful()) {

Java学习笔记(十三):Junit单元测试、反射、注解

佐手、 提交于 2020-01-25 03:34:14
foochane : https://foochane.cn/article/2020011001.html 文章目录 1. Junit单元测试 1.1 测试分类 1.2 Junit使用 1.3 判定结果 1.4 补充 1.5 代码示例 2 反射:框架设计的灵魂 2.1 框架 2.2 反射的概念 2.3 获取Class对象的方式 2.4 Class对象功能 2.5 Field:成员变量 2.6 Constructor:构造方法 2.7 Method:方法对象 3 注解 3.1 概念 3.2 注解的作用 3.4 JDK中预定义的一些注解 3.5 自定义注解 格式 本质 要求 元注解 3.6 在程序使用(解析)注解 1. Junit单元测试 1.1 测试分类 黑盒测试:不需要写代码,给输入值,看程序是否能够输出期望的值。 白盒测试:需要写代码的。关注程序具体的执行流程。 1.2 Junit使用 Junit测试属于白盒测试。 使用步骤如下: 定义一个测试类(测试用例) 如: 测试类名:被测试的类名Test CalculatorTest 包名:xxx.xxx.xx.test cn.xxxx.test 定义测试方法:可以独立运行 方法名:test测试的方法名 testAdd() 返回值:void 参数列表:空参 给方法加@Test 导入junit依赖环境 1.3 判定结果

Rest微服务案例(二)

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-25 01:05:42
1. 创建父工程 Maven Project 新建父工程microservicecloud,packaging是pom模式,pom.xml内容如下: <!-- SpringBoot父依赖 --> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.1.8.RELEASE</version> <relativePath /> </parent> <properties> <!-- jdk version --> <java.version>1.8</java.version> <!-- springcloud version --> <cloud.version>Finchley.RELEASE</cloud.version> <!-- mysql version --> <mysql.version>5.1.48</mysql.version> <!-- druid version --> <druid.version>1.1.6</druid.version> <!-- junit version --> <junit.version>4.12</junit.version> <!-- log4j