Implementing AbstractLanguageServerTest in Maven project [message #1827530] |
Sun, 17 May 2020 15:46  |
Eclipse User |
|
|
|
Hi there
Does someone know what one has to do to get the language server tests running in an Xtext project built with Maven?
In my Xtext project I develop an Eclipse plugin as well as the language server for VS code. Therefore, the Xtext project creation wizzard generates a Maven project (due to Eclipse plugin).
However, the generated Maven build is not able to execute Tests that extend the AbstractLanguageServerTest. I attached the simple "mydsl" example project here, with a language server test added to it.
The tests run perfectly fine in Eclipse, but the Maven build fails with a NullpointerException in the initialize method of the AbstractLanguageServerTest.
Any ideas how the Maven build has to be adapted for LSP tests? Has anyone such an Xtext project where this works?
Thanks for the help!
Stefan
|
|
|
|
|
|
|
|
|
|
|
|
Re: Implementing AbstractLanguageServerTest in Maven project [message #1827558 is a reply to message #1827550] |
Mon, 18 May 2020 08:08   |
Eclipse User |
|
|
|
package org.xtext.example.mydsl.tests;
import java.util.ServiceLoader;
import org.eclipse.xtext.ISetup;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
import org.junit.Assert;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class DemoTest {
@BeforeEach
public void setup() {
ServiceLoader<ISetup> sl = ServiceLoader.<ISetup>load(ISetup.class);
Assert.assertFalse(IterableExtensions.isEmpty(sl));
}
@Test
public void test02_openFile() {
}
}
shows the problem in a simply test too.
=> this seems to be a tycho bug
please ask at tycho-user mailing list
|
|
|
|
|
Re: Implementing AbstractLanguageServerTest in Maven project [message #1827563 is a reply to message #1827562] |
Mon, 18 May 2020 10:09   |
Eclipse User |
|
|
|
looks like this one works
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.xtext.example.mydsl2</groupId>
<artifactId>org.xtext.example.mydsl2.parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>org.xtext.example.mydsl2.tests</artifactId>
<packaging>eclipse-plugin</packaging>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.xtend</groupId>
<artifactId>xtend-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<executions>
<execution>
<id>test</id>
<phase>test</phase>
<configuration>
<testSourceDirectory>src,src-gen,xtend-gen,testlang-src,testlang-src-gen</testSourceDirectory>
<testClassesDirectory>target/classes</testClassesDirectory>
<failIfNoTests>true</failIfNoTests>
<includes>
<include>**/*Test.java</include>
</includes>
</configuration>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.22.1</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
a similar adaption for junit5 should work too
|
|
|
|
Powered by
FUDForum. Page generated in 0.04092 seconds