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


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



After I attempted to add the AssertJ library to my project for testing, some configuration in my project changed and I cannot import any classes from my main package into my JUnit test package.



My Main Class runs as expected, but I am unable to run any tests requiring Classes from the main package.



I've tried the following:



Looking at another project that is working it appears to be an issue with my build.gradle file




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"
}



enter image description here




1 Answer
1



The line below in the build.gradle file was failing causing the issue above.



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


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



I updated Firebase to the following and now it is still causing an issue when running tests. It appears to run fine in production:



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


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






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

List of Kim Possible characters

Audio Livestreaming with Python & Flask

NSwag: Generate C# Client from multiple Versions of an API