Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running examples in Intellij/Idea requires src/test/generated-assertions to be marked as a test source folder #36

Closed
HappyRay opened this issue Jun 5, 2017 · 18 comments

Comments

@HappyRay
Copy link

HappyRay commented Jun 5, 2017

I tried the following version:

commit 518ca73 (HEAD -> master, origin/master, origin/HEAD)
Author: Joel Costigliola [email protected]
Date: Sun May 21 15:50:31 2017 +1200

use assertj-core 3.8.0

in Intellij 2017.2.

Running
org.assertj.examples.ArrayAssertionsExamples
for example in the IDE
caused compilation errors.

After I marked src/test/generated-assertions as a test source folder, it started to work.

The README says:
"In your IDE, add src/test/generated-assertions to the project java sources if you IDE shows errors/missing classes. This folder is where custom assertions classes are generated, it shows what you have with the maven assertions generator plugin."

Is this instruction correct?

@joel-costigliola
Copy link
Member

have you run mvn clean install to generate the sources before importing the project ?

@HappyRay
Copy link
Author

HappyRay commented Jun 5, 2017

Yes.

Sample compilation errors:

assertj-examples/assertions-examples/src/test/generated-assertions/org/assertj/examples/data/bug27/AbstractMyModelClassMyBeanAssert.java
Error:(3, 28) java: package org.assertj.core.api does not exist
Error:(8, 145) java: cannot find symbol
symbol: class AbstractAssert
examples/assertj-examples/assertions-examples/src/test/generated-assertions/org/assertj/examples/data/AbstractMansionAssert.java
Error:(3, 28) java: package org.assertj.core.api does not exist
Error:(8, 111) java: cannot find symbol
symbol: class AbstractAssert
examples/assertj-examples/assertions-examples/src/test/generated-assertions/org/assertj/examples/data/AbstractBasketBallPlayerAssert.java
Error:(3, 28) java: package org.assertj.core.api does not exist
Error:(4, 28) java: package org.assertj.core.api does not exist
Error:(5, 33) java: package org.assertj.core.internal does not exist
Error:(6, 29) java: package org.assertj.core.util does not exist
Error:(11, 138) java: cannot find symbol
symbol: class AbstractAssert
examples/assertj-examples/assertions-examples/src/test/generated-assertions/org/assertj/examples/data/AbstractTeamAssert.java

@joel-costigliola
Copy link
Member

joel-costigliola commented Jun 5, 2017

is that the result of mvn clean install or the project in your IDE ?

@HappyRay
Copy link
Author

HappyRay commented Jun 5, 2017

In IDE.

mvn clean install worked fine.

@joel-costigliola
Copy link
Member

Then you haven't imported the project correctly in your IDE, from what I see assertj-core dependency is missing is your IDE project.

@HappyRay
Copy link
Author

HappyRay commented Jun 6, 2017

I imported the project by loading the pom.xml file as a project into the intellij IDE. Is there a better/correct way to import the project?

@joel-costigliola
Copy link
Member

I have reproduced the problem, it seems that Intellij Idea is not importing the project correctly, it sets test/generated-assertions as a source folder (in blue) instead of a test (in green), if you change it to a test folder in the module settings all will compile fine.

@HappyRay
Copy link
Author

HappyRay commented Jun 6, 2017

Thanks. That's what I discovered too. See the issue description.
I did a google search and couldn't find an answer.
I hope by filing an issue here at least others who run into the same problem can hopefully find a solution/workaround.

@joel-costigliola
Copy link
Member

I will update the documentation but it is an Intellij Idea problem.

Thanks for reporting this.

@HappyRay
Copy link
Author

HappyRay commented Jun 6, 2017

I understand.

Thanks!

@joel-costigliola
Copy link
Member

joel-costigliola commented Jun 6, 2017

I have just updated the README.md, can you tell me if this is clear enough ?

@HappyRay
Copy link
Author

HappyRay commented Jun 7, 2017

Yes, it is clear.

Thanks!

@HappyRay HappyRay closed this as completed Jun 7, 2017
@PrasadNutalapati
Copy link

PrasadNutalapati commented Jan 27, 2019

I am having almost the same problem with Eclipse. I am getting
package org.assertj.core.api does not exist
even though I am specifying in my pom, version 3.6.2 while using JDK 1.8.
How to overcome it ?
mvn clean install is failing.

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project com.transunion.qa.datahub.ui.java.bdd.serenity: Compilation failure: Compilation failure:

[ERROR] /Users/pnutala/eclipse-photon-workspace/com.transunion.datahub.ui.qc.java.bdd.serenity/src/main/java/com/transunion/qc/steplibrary/datahub/DeCoherentUser.java:[7,35] package org.assertj.core.api does not exist

[ERROR] /Users/pnutala/eclipse-photon-workspace/com.transunion.datahub.ui.qc.java.bdd.serenity/src/main/java/com/transunion/qc/steplibrary/datahub/DeCoherentUser.java:[7,1] static import only from classes and interfaces
[ERROR] -> [Help 1]

@joel-costigliola
Copy link
Member

Try a maven refresh project from eclipse.

@joel-costigliola
Copy link
Member

@PrasadNutalapati can you show the pom.xml ?
Please check is Basil's answer in https://stackoverflow.com/questions/54393445/cannot-resolve-symbol-assertions-error-message-when-trying-to-use-assertj addresses your issue.

@PrasadNutalapati
Copy link

I overcome this problem by removing the test for the dependency assertJ. This made the code compile and run, but the tests are not running, because the classes which invoke the assertions are in src/main/java folder.
Is there a scope which is super set of 'test' ?

@joel-costigliola
Copy link
Member

compile is I believe but you can check that on the maven doc https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope

@joel-costigliola
Copy link
Member

Have you +1 Basil's answer ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants