我们有一个普通的存储库,其中包含一些代码和测试。
一项工作有“规则”声明:
rules:
- changes:
- foo/**/*
- foo_scenarios/**/*
- .gitlab-ci.yml
Run Code Online (Sandbox Code Playgroud)
问题是, 的存在会rules导致 Gitlab 运行“独立管道”,这不是我的本意,而且很烦人。有什么方法可以禁用那些“分离”的管道,但保留该rules部分?
我在测试中使用Wiremock,并具有以下代码行:
@Rule
public WireMockRule wireMockRule = new WireMockRule(8080);
Run Code Online (Sandbox Code Playgroud)
我想切换到Junit5。因此,我添加了下一个依赖项(使用gradle):
testCompile('org.junit.jupiter:junit-jupiter-engine:5.1.1')
Run Code Online (Sandbox Code Playgroud)
但是当我尝试导入@Rule注释时没有任何建议。我是否需要添加另一个依赖于junit的模块?还是Junit5不支持规则?如果没有,我该如何替换@Rule批注以使测试再次起作用?谢谢。
我有两个配置文件:dev和default.当活动配置文件是默认时,我想跳过一些(不是全部)测试.有可能以某种方式标记这些测试吗?或者如何实现这一目标?我用springboot.这是我的父测试类:
@RunWith(SpringRunner.class)
@SpringBootTest(classes = MyServiceStarter.class, webEnvironment= SpringBootTest.WebEnvironment.DEFINED_PORT,
properties = {"flyway.locations=filesystem:../database/h2", "server.port=9100", "spring.profiles.default=dev"})
@Category(IntegrationTest.class)
public abstract class AbstractModuleIntegrationTest { ... }
Run Code Online (Sandbox Code Playgroud) 在我们的项目中,我们使用jacoco-maven-plugin并在构建过程中出现此错误:
[ERROR] Failed to execute goal org.jacoco:jacoco-maven-plugin:0.8.5:check (jacoco-check) on project my-project: Coverage checks have not been met. See log for details.
Run Code Online (Sandbox Code Playgroud)
我知道最好修复覆盖范围等等。但有时我只需要快速构建一个项目。是否有某种参数用于此目的?喜欢mvn clean install -Dskip.jacoco.check=true或其他方式快速跳过此检查?
我有这个简单的代码:
@Data
@Builder
public class RegistrationInfo {
private String mail;
private String password;
public RegistrationInfo(RegistrationInfo registrationInfo) {
this.mail = registrationInfo.mail;
this.password = registrationInfo.password;
}
}
Run Code Online (Sandbox Code Playgroud)
首先,我只使用了@BuilderLombok批注,一切都很好。但是我添加了构造函数,并且代码不再编译。错误是:
Error:(2, 1) java: constructor RegistrationInfo in class com.user.RegistrationInfo cannot be applied to given types;
required: com.user.RegistrationInfo
found: java.lang.String,java.lang.String
reason: actual and formal argument lists differ in length
Run Code Online (Sandbox Code Playgroud)
所以我有两个问题:
@Builder与此构造函数不兼容?我创建了一个简单的测试来尝试Junit 5:
import org.junit.jupiter.api.Test;
public class MyTest {
@Test
public void testJupiter() {
System.out.println("test");
}
}
Run Code Online (Sandbox Code Playgroud)
这是我使用的依赖:
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.0.0</version>
<scope>test</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)
堆栈跟踪是下一个:
Exception in thread "main" java.lang.NoSuchMethodError: org.junit.platform.commons.util.ReflectionUtils.getDefaultClassLoader()Ljava/lang/ClassLoader;
at org.junit.platform.launcher.core.ServiceLoaderTestEngineRegistry.loadTestEngines(ServiceLoaderTestEngineRegistry.java:30)
at org.junit.platform.launcher.core.LauncherFactory.create(LauncherFactory.java:53)
at com.intellij.junit5.JUnit5IdeaTestRunner.createListeners(JUnit5IdeaTestRunner.java:39)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:49)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Run Code Online (Sandbox Code Playgroud)
出了什么问题?
I\xe2\x80\x99m 试图捕获 NoSuchElementException。这是我的代码:
\n\npublic void checkActiveApps() {\n try {\n $(BUTTON).click();\n } catch (org.openqa.selenium.NoSuchElementException e) {\n System.out.println(e);\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n\n但仍然抛出异常。怎样才能抓住它呢?
\n\n这是日志:
\n\nElement not found {button[role='checkbox']}\nExpected: visible\nScreenshot: file:/Users/user/source/project/build/reports/tests/1537866631954.0.png\nPage source: file:/Users/user/source/project/build/reports/tests/1537866631954.0.html\nTimeout: 4 s.\nCaused by: NoSuchElementException: Unable to locate element: button[role='checkbox']\n at com.codeborne.selenide.impl.WebElementSource.createElementNotFoundError(WebElementSource.java:31)\n at com.codeborne.selenide.impl.ElementFinder.createElementNotFoundError(ElementFinder.java:82)\n at com.codeborne.selenide.impl.WebElementSource.checkCondition(WebElementSource.java:59)\n at com.codeborne.selenide.impl.WebElementSource.findAndAssertElementIsVisible(WebElementSource.java:72)\n at com.codeborne.selenide.commands.Click.execute(Click.java:16)\n at com.codeborne.selenide.commands.Click.execute(Click.java:12)\n at com.codeborne.selenide.commands.Commands.execute(Commands.java:144)\n at com.codeborne.selenide.impl.SelenideElementProxy.dispatchAndRetry(SelenideElementProxy.java:90)\n at com.codeborne.selenide.impl.SelenideElementProxy.invoke(SelenideElementProxy.java:65)\nRun Code Online (Sandbox Code Playgroud)\n\n我使用selenide版本4.12.3
\n在集成测试类中,我遇到了以下代码行:
@ClassRule
public static final SpringClassRule SPRING_CLASS_RULE = new SpringClassRule();
@Rule
public final SpringMethodRule springMethodRule = new SpringMethodRule();
Run Code Online (Sandbox Code Playgroud)
当我尝试导航到课程时(我使用Intellij Idea)我得到'找不到声明去'.当我试图找到用法时,我得到"项目中没有找到用法"我熟悉规则的概念.但仍然不明白这两件事做了什么.我查看了这个页面:https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/ 没有信息.
我@AllArgsConstructor在我的班级中使用了注释,并希望确保参数不为空。有没有办法修改此注释以使其成为可能,或者我应该实现构造函数?谢谢
@Getter
@Setter
@ToString
@AllArgsConstructor
public class Contact {
private String name;
private String phoneNumber;
}
Run Code Online (Sandbox Code Playgroud)
...
<lombok.version>1.16.18</lombok.version>
Run Code Online (Sandbox Code Playgroud) 我在项目中创建了一个简单的 gradle 插件。根据文档,它应该没问题,但是当我尝试使用它时,我得到了Plugin with id 'show-date-plugin' not found.
我指的文档:
https: //docs.gradle.org/current/userguide/custom_plugins.html
您可以将插件的源代码放在 rootProjectDir/buildSrc/src/main/groovy 目录中。Gradle 将负责编译和测试插件,并使其在构建脚本的类路径上可用。该插件对于构建使用的每个构建脚本都是可见的。但是,它在构建之外不可见,因此您无法在定义它的构建之外重用该插件。
这是我的build.gradle
plugins {
id 'java'
id 'groovy'
}
group 'info.garagesalesapp'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
compile 'org.codehaus.groovy:groovy-all:2.4.12'
compile gradleApi()
compile localGroovy()
compile project(':json-display')
testCompile group: 'junit', name: 'junit', version: '4.12'
}
apply plugin: 'project-report'
apply plugin: 'show-date-plugin'
Run Code Online (Sandbox Code Playgroud)
那么我做错了什么?