Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/349.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 运行测试用例时获取BuildResultLogger错误_Java_Spring Boot_Gradle - Fatal编程技术网

Java 运行测试用例时获取BuildResultLogger错误

Java 运行测试用例时获取BuildResultLogger错误,java,spring-boot,gradle,Java,Spring Boot,Gradle,我正在尝试为我的应用程序实现测试用例。当我运行我的测试用例时,我得到了低于错误的结果。请在下面找到my build.gradle、测试文件和错误日志。我的应用程序基于使用gradle的spring启动框架 项目代码中使用的build.gradle文件 buildscript { ext { springBootVersion = "2.4.0" mavenUrl = "https://artifacts.XXX.int/art

我正在尝试为我的应用程序实现测试用例。当我运行我的测试用例时,我得到了低于错误的结果。请在下面找到my build.gradle、测试文件和错误日志。我的应用程序基于使用gradle的spring启动框架

项目代码中使用的build.gradle文件

buildscript {
    ext {
        springBootVersion = "2.4.0"
        mavenUrl = "https://artifacts.XXX.int/artifactory/maven-all"
    }
    repositories {
        maven {
            url = mavenUrl
        }
    }
    dependencies {
        classpath "org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}"
    }
}


repositories {
    mavenLocal()
    maven { url = mavenUrl }
}

apply plugin: 'checkstyle'
apply plugin: 'idea'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'org.springframework.boot'
apply plugin: 'pmd'

group = 'com.xxx.test'
version = '1.0'

sourceCompatibility = 1.8
targetCompatibility = 1.8

test {
    useJUnitPlatform()
}

dependencies {
    implementation 'junit:junit:4.12'
    compile group: 'com.google.code.findbugs', name: 'findbugs-annotations', version: '3.0.1'
    implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web'
    implementation group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa'
    implementation group: 'io.springfox', name: 'springfox-swagger2', version: '2.9.0'
    implementation group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.9.0'
    implementation group: 'org.postgresql', name: 'postgresql'

    compileOnly 'org.projectlombok:lombok:1.18.16'
    annotationProcessor 'org.projectlombok:lombok:1.18.16'

    testCompileOnly 'org.projectlombok:lombok:1.18.16'
    testAnnotationProcessor 'org.projectlombok:lombok:1.18.16'

    // Test only dependencies
    compile('org.springframework.boot:spring-boot-starter')
    compile group: 'org.mockito', name: 'mockito-core', version: '2.13.0'
    testCompile('org.springframework.boot:spring-boot-starter-test')
}

apply from: "$rootDir/codequality.gradle"
项目中使用的测试类

package com.xxx.test.yyy;

import com.xxx.test.yyy.header.NTuDataRepo;
import com.xxx.test.yyy.model.NTuData;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.sql.Date;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

import static org.junit.jupiter.api.Assertions.assertEquals;


@SpringBootTest
@RunWith(SpringJUnit4ClassRunner.class)
public class TestServiceTests {

            @Mock
            NTuDataRepo ntuDataRepo;

    

            @BeforeAll
            public static void setUp() throws Exception {
            }

            @AfterAll
            public static void tearDown() throws Exception {}

            @Test
            void contextLoads() {
            }

            @Test
            public void testGetCurrentNTuData() throws Exception{
                        UUID uuid = UUID.fromString("123e4567-e89b-12d3-a456-556642440000");
                        String effect = "test-effect";
                        String value = "test-value";
                        Date dateFrom = new Date(2323223232L);
                        Date dateTo = new Date(2323223232L);

                        NTuData ntuData = new NTuData();
                        ntuData.setId(uuid);
                        ntuData.setEffect(effect);
                        ntuData.setValue(value);
                        ntuData.setDateFrom(dateFrom);
                        ntuData.setDateTo(dateTo);

                        List<NTuData> ntuData = new ArrayList<NTuData>();
                        ntuData.add(ntuData);


                        Mockito.when(this.ntuDataRepo.currentHeaders()).thenReturn(ntuData);

                        List<NTuData> test = ntuDataRepo.currentHeaders();

                        assertEquals(effect, test.get(0).getEffect());
                       
            }


}

2021-05-27T13:26:02.967-0400 [DEBUG] [org.gradle.internal.resources.AbstractTrackedResourceLock] Daemon worker Thread 2: released lock on root.1
2021-05-27T13:26:02.967-0400 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
2021-05-27T13:26:02.967-0400 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception.
2021-05-27T13:26:02.967-0400 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
2021-05-27T13:26:02.967-0400 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * What went wrong:
2021-05-27T13:26:02.967-0400 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Execution failed for task ':compileTestJava'.
2021-05-27T13:26:02.968-0400 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > Could not resolve all files for configuration ':testCompileClasspath'.
2021-05-27T13:26:02.968-0400 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]    > Could not resolve org.mockito:mockito-junit-jupiter:3.6.0.
2021-05-27T13:26:02.968-0400 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]      Required by:
2021-05-27T13:26:02.968-0400 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]          project : > org.springframework.boot:spring-boot-starter-test:2.4.0
2021-05-27T13:26:02.968-0400 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]       > Could not resolve org.mockito:mockito-junit-jupiter:3.6.0.
2021-05-27T13:26:02.968-0400 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]          > Could not parse module metadata https://artifacts.xxx.int/artifactory/maven-all/org/mockito/mockito-junit-jupiter/3.6.0/mockito-junit-jupiter-3.6.0.module
2021-05-27T13:26:02.968-0400 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]             > Use JsonReader.setLenient(true) to accept malformed JSON at line 2 column 1 path $
2021-05-27T13:26:02.968-0400 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
2021-05-27T13:26:02.968-0400 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Try:
2021-05-27T13:26:02.968-0400 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Run with --stacktrace option to get the stack trace.  Run with --scan to get full insights.
2021-05-27T13:26:02.968-0400 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
2021-05-27T13:26:02.968-0400 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Get more help at https://help.gradle.org
2021-05-27T13:26:02.968-0400 [WARN] [org.gradle.internal.featurelifecycle.LoggingDeprecatedFeatureHandler] 
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.8.2/userguide/command_line_interface.html#sec:command_line_warnings
2021-05-27T13:26:02.969-0400 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger] 
2021-05-27T13:26:02.969-0400 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger] BUILD FAILED in 5s
2021-05-27T13:26:02.969-0400 [LIFECYCLE] [org.gradle.internal.buildevents.TaskExecutionStatisticsReporter] 3 actionable tasks: 2 executed, 1 up-to-date