ICode9

精准搜索请尝试: 精确搜索
  • java-如何参数化junit测试套件2019-11-22 03:03:17

    是否可以在junit 4中参数化TestSuite? 为了将一个类声明为测试套件,我需要注释@RunWith(Suite.class),但是还需要使用相同的注释将测试声明为参数化:@RunWith(Parameterized.class),因此我无法将两者都添加到同一类. 我在此站点发现了一个类似的question,并没有太大帮助.到目前为止,

  • java-具有JUnit临时文件夹的Spring Config2019-11-21 13:21:13

    嗨,我正在寻找一种在Spring配置文件中使用JUnit的TemporaryFolder的方法.但是我收到以下错误. Caused by: java.lang.IllegalStateException: the temporary folder has not yet been created at org.junit.rules.TemporaryFolder.getRoot(TemporaryFolder.java:127) at org

  • 将参数传递给Spring测试2019-11-21 12:19:32

    我们有一个标准的Spring测试类,可以加载应用程序上下文: @ContextConfiguration(locations = {"classpath:app-context.xml" }) @RunWith(SpringJUnit4ClassRunner.class) public class AppTest { ... } XML上下文使用标准的占位符,例如:${key}正常运行整个应用程序(而不是作为

  • java-不引发测试异常2019-11-19 16:01:53

    我正在创建一个集成测试: @RunWith(CdiRunner.class) @AdditionalClasses({FollowUpActivityRepository.class, SettingsPropertiesProducer.class}) public class FollowUpActivityFeaturesTest { @Inject protected FollowUpActivityService fuaService; @Test public vo

  • java.time.format.DateTimeParseException: Text '2019-10-11 12:30:30' could not be parsed at2019-11-12 13:55:08

    java.time.format.DateTimeParseException: Text '2019-10-11 12:30:30' could not be parsed at index 10 at java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:1949) at java.time.format.DateTimeFormatter.parse(DateTimeFo

  • 休眠-事务不会在Spring Test中回滚以进行删除操作2019-11-02 22:28:39

    在进行弹簧测试时,某种程度上我的测试不会回滚删除事务.数据将被永久删除.  我正在使用Spring-Hibernate组合. 这是我的测试课: @RunWith(SpringJUnit4ClassRunner.class) @TestExecutionListeners( {TransactionalTestExecutionListener.class, DependencyInjectionTestExecuti

  • java-Spring集成测试事务未回滚2019-11-02 17:29:38

    为基于Spring的应用程序编写集成测试遇到事务回滚问题-插入了数据,但是在事务回滚后,数据仍在数据库表中… Spring 3.0.5,JUnit 4.8.2 集成测试代码 @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath:/applicationContext.xml" }) @Trans

  • java-如何在testet方法内使用断言编写单元测试?2019-11-01 14:10:32

    我有一个问题,我想测试一些在我的junit测试中被其他方法隐藏的值.你怎么会这样.和Mockito在一起吗?子类化? 这里的问题: public class MyService extends AbstractService { public ResponseObject insert(SomeData data) { Request request = createRequest(data); Resp

  • Java-Spring Web Flow:设置JUnit测试的请求参数2019-11-01 10:19:25

    介绍 我有一个Java / Tomcat / Spring 2.5 / Spring Webflow 2.0.9 Web应用程序.为了测试某些页面,我创建了JUnit测试,该测试将值设置为表单对象并模仿来自浏览器的请求. JUnit测试类如下所示: @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class }) @Cont

  • java-模拟多次调用的静态方法2019-10-31 01:01:02

    我有一个静态方法,该方法在多个地方使用,主要是在静态初始化块中使用.它以Class对象为参数,并返回该类的实例. 我只想在将特定的Class对象用作参数时模拟此静态方法.但是,当从其他地方使用不同的Class对象调用该方法时,它将返回null.如果参数不是模拟参数,我们如何让静态方法执行实

  • Android Studio找不到JUnit套件2019-10-27 21:24:21

    我似乎无法获得测试文件来查找Junit4.我一直在努力,但感到沮丧.它说在组织下找不到符号junit.我搜索过的所有内容(几天),甚至android文档都说这是做到这一点的方法.我究竟做错了什么? 这是我的考试课 import org.junit.Test; import android.app.Application; public class Appl

  • android-在JUnit4和Mockito中编写SQLiteOpenHelper测试用例2019-10-27 09:27:08

    我正在尝试为我的数据库编写测试用例. 我有一个扩展到SQLiteOpenHelper的帮助程序类 DBHelper.java public DBHelper(Context context) { super(context, DBConstants.DATABASE_NAME, null, DBConstants.DATABASE_VERSION); } 以及具有所有插入,删除

  • java-如何在junit测试中捕获所有非caucht异常?2019-10-27 05:02:46

    如果我们创建了一个Singleton对象来处理Java异常,为什么Thread.setDefaultUncaughtExceptionHandler可以在Java Application Server Java控制台应用程序中正常运行,但不能在JUnit测试中运行? 例如,以下代码有效: public class Main extends Object { public static void main(S

  • java-如何给具有相同id的spring bean优先?2019-10-26 09:20:06

    在我们的项目中,我们将Spring与Junit一起用于Junit测试.我们已经使用@ContextConfiguration批注来加载多个文件.我们有两个类AbstractContextJUnitTest和ContextJUnitTest,而ContextJUnitTest扩展了AbstractContextJUnitTest. 在代码流中,我注意到多个文件中具有相同bean类型的同一

  • java-加载测试的系统属性2019-10-23 18:00:15

    最近,我找到了一个解决方案,可以让我为单元测试加载系统属性.如果我单独运行测试,效果很好,但是如果选择运行整个测试套件,它将失败.有人可以告诉我为什么吗? 第一步是加载测试应用程序上下文: @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = "/applic

  • 如何解决NoSuchMethodError2019-10-21 19:54:17

    背景 工作中写单测,本来用的Mockito,但是为了mock方法里调用的其他静态方法,所以需要使用powermock,于是开始报错。 我把包引入了,然后照着网上的写单测代码,写完了之后运行。噩梦开始。 报错一 java.lang.NoSuchMethodError: org.mockito.internal.progress.ThreadSafeMockingProgress

  • java-无法使用gradle按类别包括/排除Junit测试类2019-10-12 04:05:46

    给定这些接口 testclient.priority.High testclient.priority.Low 和一个这样注释的junit类 @Category(testclient.priority.High.class) public class MyTest { ... } @Category(testclient.priority.Low.class) public class MyOtherTest { ... } 我试图像这样在build.gradle

  • java – 我在Mockito 2.2中使用什么代替Whitebox来设置字段?2019-10-07 19:01:10

    当使用Mockito 1.9.x时,我一直在使用Whiteboxto设置字段值来“注入”模拟.以下示例: @Before public void setUp() { eventHandler = new ProcessEventHandler(); securityService = new SecurityServiceMock(); registrationService = mock(RegistrationService.clas

  • 如何使用Gradle运行JUnit测试?2019-10-03 19:11:27

    目前我有以下build.gradle文件: apply plugin: 'java' sourceSets { main { java { srcDir 'src/model' } } } dependencies { compile files('libs/mnist-tools.jar', 'libs/gson-2.2.4.jar')

  • java – JUnit测试预期异常的正确方法2019-10-01 02:04:34

    大家好我想知道这种测试我的异常的方法是否正常,我有这个例外我需要抛出第二个测试注释,我接收结果是一个红色的邪恶吧,一个成功和一个失败,你可以猜到失败是我关心的,我有失败();但原因是因为我读到了测试异常的方法,现在我很困惑. 此外,我不得不说im willin得到绿色条,因为我期待

  • java – 在同一版本中执行JUnit 4和JUnit 5测试2019-09-30 13:01:18

    在Maven项目中,我有一些现有的测试依赖于JUnit 4.由于多种原因,我无法在JUnit 5中迁移这些测试. 实质上,一些测试依赖于使用JUnit 4 runner的库,代码迁移可能需要一些时间. 我想用JUnit 5创建新的测试类,现在已经发布并提供了新的有趣功能.怎么做 ?解决方法:JUnit 5提供了a way out

  • 在Spring Tests上禁用@EnableScheduling2019-09-23 15:18:47

    当我运行我的单元测试时,它会调用我的计划任务.我想防止这种行为,这是因为我的主应用程序配置上有@EnableScheduling这一事实. 如何在单元测试中禁用此功能? 我遇到过这个question/answer,建议设置个人资料? 不确定我会怎么做?或者如果它有点矫枉过正?我正在考虑为我的单元测试使用单独

  • java – JUnit4是否开始支持测试的排序?这是故意的吗?2019-09-23 06:13:36

    JUnit的新手(事实上是JUnit 4)并且遇到了执行测试的套件方式 @RunWith(Suite.class) @Suite.SuiteClasses( { CreateNewProfile.class, EditProfile.class, }) public class ProfileTestSuite {

  • java – Mockito:模拟私有字段初始化2019-09-19 00:02:27

    我如何模拟正在内联初始化的字段变量? 例如 class Test { private Person person = new Person(); ... public void testMethod() { person.someMethod(); ... } } 在这里,我想在测试方法时测试person.someMethod() – Test#testMethod. 我需要

  • java – 如何断言在JUnit 4测试中抛出某个异常?2019-09-11 02:02:05

    如何以惯用方式使用JUnit4来测试某些代码是否会抛出异常? 虽然我当然可以这样做: @Test public void testFooThrowsIndexOutOfBoundsException() { boolean thrown = false; try { foo.doStuff(); } catch (IndexOutOfBoundsException e) { thrown = true; } as

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有