MopeSWTP-SS21 / MopeSWTP

MIT License
1 stars 0 forks source link

Write first JUnit-Test #34

Closed manuEbg closed 3 years ago

manuEbg commented 3 years ago
  1. Start LanguageServer
  2. Start Language Client
  3. Initialize Server
  4. Request OMC Version
  5. Check Result

This Test needs to be triggered via GitHub Actions

manuEbg commented 3 years ago

After my commit https://github.com/MopeSWTP-SS21/LspConsole/commit/74254368c02ea7e22e9082ccedf846e8dad5fea6 the class naming should be right

manuEbg commented 3 years ago

this line https://github.com/MopeSWTP-SS21/LspConsole/blob/8ff951ed6031e81619cf7e9bf470752213ba3859/build.gradle#L31

produces the following error during gradle build or gradle <taskName> when run from the console. However no problems in IntelliJ ...

FAILURE: Build failed with an exception.

* Where:
Build file '/home/swtp/LspConsoleJava/build.gradle' line: 31

* What went wrong:
A problem occurred evaluating root project 'LspConsoleJava'.
> Could not find method useJUnitPlatform() for arguments [] on task ':test' of type org.gradle.api.tasks.testing.Test.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 2s

i dont care for now, because we dont have test yet and i can comment it out. But maybe @CptKaNe should care when developing the first Test :)

CptKaNe commented 3 years ago

After my commit: MopeSWTP-SS21/LspConsole@995ee075a85e99147b0d087dcf0e3aaaf348b412

the first test works fine, even if there is a little bit space of improvement concerning the CompletableFutures as we discussed, manu. Besides, I refactored the project structure to seperate the test module from the main module.

My aim is now to get the test triggered via Github Actions, but before i want to inspect the error you mentioned above as i am also running in it via terminal while having no problems in intellij.

manuEbg commented 3 years ago

After my commits (https://github.com/MopeSWTP-SS21/LspConsole/commit/995ee075a85e99147b0d087dcf0e3aaaf348b412)

the first test works fine, even if there is a little bit space of improvement concerning the CompletableFutures as we discussed, manu. Besides, I refactored the project structure to seperate the test module from the main module.

My aim is now to get the test triggered via Github Actions, but before i want to inspect the error you mentioned above as i am also running in it via terminal while having no problems in intellij.

I think the Link U posted is a bit broken? Did U experienced the same Error? I hoped the Error might disappear into air once we have a test...

CptKaNe commented 3 years ago

After my commits (https://github.com/MopeSWTP-SS21/LspConsole/commit/995ee075a85e99147b0d087dcf0e3aaaf348b412) the first test works fine, even if there is a little bit space of improvement concerning the CompletableFutures as we discussed, manu. Besides, I refactored the project structure to seperate the test module from the main module. My aim is now to get the test triggered via Github Actions, but before i want to inspect the error you mentioned above as i am also running in it via terminal while having no problems in intellij.

I think the Link U posted is a bit broken? Did U experienced the same Error? I hoped the Error might disappear into air once we have a test...

thanks for the hint, i fixed the link. i did experienced the same error and think we have to care about since we got a working test

CptKaNe commented 3 years ago

After a little research i found several issues, i.e this https://github.com/synthetichealth/synthea/issues/473 it seems that we have to update our gradle, since this solved the problem for others using gradle with JDK 11.

gradle --version output was:

Gradle 4.4.1

Build time: 2012-12-21 00:00:00 UTC

Revision: none

Groovy: 2.4.20 Ant: Apache Ant(TM) version 1.10.8 compiled on January 8 1970 JVM: 11.0.11 (Ubuntu 11.0.11+9-Ubuntu-0ubuntu2.20.10) OS: Linux 5.11.0-7614-generic amd64

According to the linked issue this problem is fixed since gradle 5.0-milestone-1

manuEbg commented 3 years ago

@CptKaNe this Link does not work either...

After a little research i found several issues, i.e this https://github.com/synthetichealth/synthea/issues/473 it seems that we have to update our gradle, since this solved the problem for others using gradle with JDK 11.

gradle --version output was:

Gradle 4.4.1

Build time: 2012-12-21 00:00:00 UTC

Revision: none

Groovy: 2.4.20 Ant: Apache Ant(TM) version 1.10.8 compiled on January 8 1970 JVM: 11.0.11 (Ubuntu 11.0.11+9-Ubuntu-0ubuntu2.20.10) OS: Linux 5.11.0-7614-generic amd64

According to the linked issue this problem is fixed since gradle 5.0-milestone-1

I think this is very odd. The current Version of gradle is 7.0.2. Why would we install a nearly 10 year old version??

I think its time to update:)

CptKaNe commented 3 years ago

I did further research and decided to try to set up the gradle wrapper, since it has the benefit that every dev can build/run our project independent from their gradle version.

To do so, I followed several steps from different sources: https://tomgregory.com/how-to-update-gradle/ https://stackoverflow.com/questions/25769536/how-when-to-generate-gradle-wrapper-files/25770202#25770202?newreg=414a43d752eb48f58917fbec0193ccaf https://stackoverflow.com/questions/54358107/gradle-could-not-determine-java-version-from-11-0-2

I try to sum up the steps that worked for me in the following:

  1. Open Terminal in Intellij / Open Terminal and head to root project folder (LSPConsoleJava)
  2. Execute gradle wrapper -> the missing jar will be added
  3. check version ./gradlew --version -> an old version is printed
  4. Execute ./gradlew wrapper --gradle-version=7.0.2 -> step 3 to check the version

After these steps i ran into another error concerning the build.gradle file:

A Problem occurred evaluating root project 'LSPConsoleJava'. Could not find mehtod compile() for arguments [org.eclipse-lsp4j:0.12.0] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

According to this post https://stackoverflow.com/a/66910991 some keywords like compile are deprecated since gradle 4.10

Replacing the three compile commands in the build.gradle with implementation solves this problem.

now it is possible to execute

so that every build is successful. These minimal changes can be found in this commit: MopeSWTP-SS21/LspConsole@53e6572f01db8b1d1dafb29cc4bcb5fe9f830a8d