繁体   English   中英

无法从主Java目录导入到测试目录(IntelliJ)

[英]Unable to Import From main Java Directory Into test Directory (IntelliJ)

尝试将AssertJ库添加到项目中以进行测试后,项目中的某些配置发生了更改,并且无法将包中的任何类导入到JUnit 测试包中。

我的主类按预期运行,但是我无法运行任何需要主软件包中的类的测试。

我尝试了以下方法:

  • 删除AssertJ导入
  • 重建项目
  • 刷新所有Gradle项目
  • 使IntelliJ缓存无效从设置重新启动
  • 在本地删除项目并从GitHub重新下载
  • 删除测试目录并重新添加

查看正在运行的另一个项目,这似乎与我的build.gradle文件有关

 group 'carpecoin' version '1.0-SNAPSHOT' buildscript { ext.kotlin_version = '1.2.41' ext.junitJupiterVersion = '5.0.3' repositories { mavenCentral() } dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.3' } } apply plugin: 'java' apply plugin: 'kotlin' sourceCompatibility = 1.8 repositories { mavenCentral() } dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" testImplementation group: 'junit', name: 'junit', version: '4.12' // JUnit Jupiter API and TestEngine implementation testCompile("org.junit.jupiter:junit-jupiter-api:${junitJupiterVersion}") testRuntime("org.junit.jupiter:junit-jupiter-engine:${junitJupiterVersion}") // To avoid compiler warnings about @API annotations in JUnit code testCompileOnly('org.apiguardian:apiguardian-api:1.0.0') implementation 'com.squareup.retrofit2:retrofit:2.3.0' implementation 'com.squareup.retrofit2:converter-gson:2.3.0' implementation 'com.squareup.retrofit2:adapter-rxjava:2.3.0' implementation 'io.reactivex.rxjava2:rxjava:2.1.1' implementation 'com.google.firebase:firebase-admin:6.0.0' implementation 'com.google.firebase:firebase-database:15.0.0' } compileKotlin { kotlinOptions.jvmTarget = "1.8" } compileTestKotlin { kotlinOptions.jvmTarget = "1.8" } 

在此处输入图片说明

build.gradle文件中的以下行失败导致上述问题。

implementation 'com.google.firebase:firebase-database:15.0.0'

我将Firebase更新为以下内容,现在在运行测试时仍会引起问题。 它似乎在生产中运行良好:

implementation 'com.google.firebase:firebase-core:16.0.1'

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM