草庐IT

structuring-unit-tests

全部标签

java - 具有多个@Test 方法的 Junit 测试类

我有一个Junit测试类,其中包含多个@Test方法,我需要按顺序运行这些方法。如果方法中抛出异常,我想停止整个测试用例并出错,但所有其余测试方法都在运行。publicclass{@Test{//Test1method`entercodehere`}@Test{//Test2method}@Test{//Test3method}}如果Test1方法失败则不要运行其他测试注:均为独立测试 最佳答案 单元测试应设计为彼此独立运行。无法保证执行顺序。你应该重新设计你的测试类,这样顺序就不重要了。如果没有进一步的信息,很难给您具体的建议。但

linux Shell 命令行-05-test 检查某个条件是否成立

拓展阅读linuxShell命令行-00-intro入门介绍linuxShell命令行-02-var变量linuxShell命令行-03-array数组linuxShell命令行-04-operator操作符linuxShell命令行-05-test验证是否符合条件linuxShell命令行-06-flowcontrol流程控制linuxShell命令行-07-func函数linuxShell命令行-08-fileinclude文件包含linuxShell命令行-09-redirect重定向基本输出echoecho[-e]字符串printf类似于C的printf()函数printf格式化字符串

java - dropwizard-testing 资源测试在构建 ResourceTestRule 时爆炸

我有一个我正在尝试设置的简单ResourceTest,但是当我尝试构建ResourceTestRule时,出现以下异常:ProfilesResourceTest,shouldGetEmptyStuffWARN[2016-05-1517:44:50,159]org.glassfish.jersey.internal.Errors:Thefollowingwarningshavebeendetected:WARNING:HK2servicereificationfailedfor[com.sun.jersey.core.impl.provider.entity.MimeMultipartP

java - eclipse : XML document structures must start and end within the same entity 中的 SaxParseException

我正在使用JAVA的last.fmAPI,可以找到here.我有一个巨大的Dataset其中我只使用包含用户艺术家历史和播放的文件。我用Java编写了一段代码,它提取这些艺术家姓名并根据Artist.getSimilar()方法返回相似的艺术家。我运行了一次,但不是为所有艺术家运行的。我中途终止了调试。然而下一次,我的结果从缓存中返回,请求不再发送到网络服务器。问题是,这次我只得到结果,直到我终止结果的艺术家。我尝试对artists=Artist.getTopAlbums()使用另一种方法,我中途终止并在下次遇到同样的问题。我得到的错误是:[FatalError]:513:9:XMLd

java - Gradle,错误找不到或加载主类 'test.Main'

我在one上实现了Gradle我的项目。我将Netbeans8.02与gradle插件一起使用。结构应该是这样的,源码在jgli/src/main/java/下,资源在jgli/src/main/resources/下>主类是jgli/src/main/java/test/Main.java如果我通过ide运行它,它会在Windows上运行,它crashes在Linux上。这就是我现在尝试通过控制台运行它的原因:java-jarjgli.jar但我不断得到:Errorcouldnotfindorloadmainclass'test.Main'这是我的build.gradleapplyp

java - 配置 maven-failsafe-plugin 以查找不在 src/test/java 中的集成测试

我的目录结构是这样的:src/integrationTest/javasrc/test/javasrc/main/java我正试图通过故障保护来进行集成测试,但未能按照我希望的方式进行。我试过这个:maven-failsafe-plugin2.17integration-testverifysrc/integrationTest/java${project.build.directory}/it-classes还有这个:maven-failsafe-plugin2.17integration-testverifysrc/integrationTest/**/*.java无济于事;fai

java - 名称冲突 : The method add(Object) of type test2 has the same erasure as add(E) of type HashSet<E> but does not override it

导入java.util.*;classAextendsHashSet{publicbooleanadd(Objectobj){//compilererrorreturntrue;}}orclassAbc{publicvoidadd(Tt){}//compilererrorpublicvoidadd(Objecti){}//compilererror(can'toverload?)}错误:名称冲突:test2类型的方法add(Object)与HashSet类型的add(E)具有相同的删除,但没有覆盖它我不知道上述错误背后的概念是什么,有人可以建议我在哪里可以研究这个概念吗?

java - Datanucleus 警告 : Class was specified in persistence-unit but not annotated, 所以忽略

启动我的应用程序时,我会为每个类看到此警告:WARN[DataNucleus.MetaData]-Classcom.mycomp.MyClasswasspecifiedinpersistence-unitmyPersistenceUnitbutnotannotated,soignoring该应用程序正确启动,因此没有直接问题,但我想知道这个即将到来的形式,以及如何避免id。我的persistence.xml看起来像:org.datanucleus.api.jpa.PersistenceProviderImpl我正在使用Spring在GoogleAppEngine上运行我的应用程序。但我

java - SonarQube 问题 "Add at least one assertion to this test case"用于带有断言的单元测试?

我在使用SonarQube时遇到问题,我的几个单元测试出现了问题,提示了以下问题:Addatleastoneassertiontothistestcase.每个测试用例都类似于这种格式(其中许多断言被委托(delegate)给具有公共(public)断言的方法,以避免重复):@TestpublicvoidcompanyNameOneTooLong()throwsException{AddressFormBeanformBean=getValidBean();formBean.setCompanyNameOne("123456789012345678901234567890123456"

java - Sonar Java : check the quality of the test classes source code?

是否可以在Sonar中检查*Test.java源代码的质量,例如方法最大尺寸100行?问题是,JavaJunit测试随着生产代码的增加而增加,复杂性也在增加。我们有超过1000行和2个方法的单元测试类。我们想在Sonar中检查这些*Test.java类的一些规则。 最佳答案 从Sonar3.1开始,它包含一个插件,该插件具有针对单元测试执行的特定PMD规则(aJIRAwascreatedforthat)。您可以在Configuration>QualityProfiles>CodingRules中看到它们。但是,您似乎想要对测试源代码