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

Unit tests coded in scala based on junit testing framework are not recognized #7036

Open
JixiangZeng opened this issue Dec 17, 2024 · 1 comment
Labels
upstream-fix-needed Waiting on a fix upstream

Comments

@JixiangZeng
Copy link

Describe the bug

Springboot microservice project coded in Scala, in which the Scala unit test based on the JUnit test framework cannot find the execution entry.
It can be executed normally in the idea development tool.

Screenshots

image
image

Installation:

  • Operating system: Linux
  • scala:2.11.12
  • Scala (Metals) v1.44.0
  • Metals version:1.2.0

Additional context

import org.junit.jupiter.api.Test
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class ScTest {
  @Test
  def prints() {
    println("abc")
  }
}

maven project pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<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>

    <groupId>com.zjx</groupId>
    <artifactId>javascalademo</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>
    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        <scala.version>2.11.12</scala.version>
    </properties>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.18</version>
    </parent>

    <dependencies>
        <!-- JUnit 5 API -->
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>5.7.1</version>
            <scope>test</scope>
        </dependency>
        <!-- JUnit 5 Engine -->
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>5.7.1</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>

        </dependency>

        <dependency>
            <groupId>com.novocode</groupId>
            <artifactId>junit-interface</artifactId>
            <version>0.11</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.scalatest</groupId>
            <artifactId>scalatest_2.11</artifactId>
            <version>3.2.16</version>
            <scope>test</scope>
        </dependency>

    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>net.alchim31.maven</groupId>
                <artifactId>scala-maven-plugin</artifactId>
                <version>3.2.2</version>
                <executions>
                    <execution>
                        <id>scala-compile-first</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>add-source</goal>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>scala-test-compile</id>
                        <phase>process-test-resources</phase>
                        <goals>
                            <goal>testCompile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.0.0</version>
                <configuration>
                    <useModulePath>false</useModulePath>
                    <argLine>-Dfile.encoding=UTF-8</argLine>
                    <includes>
                        <include>**/*Test*.java</include>
                        <include>**/*Test*.scala</include>
                    </includes>
                </configuration>
            </plugin>

        </plugins>
    </build>
</project>
@tgodzik tgodzik transferred this issue from scalameta/metals-vscode Dec 17, 2024
@kasiaMarek kasiaMarek added upstream-fix-needed Waiting on a fix upstream and removed investigation needed labels Jan 7, 2025
@kasiaMarek
Copy link
Contributor

Bloop doesn't currently support JUnit 5. Upstream issue: scalacenter/bloop#996

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
upstream-fix-needed Waiting on a fix upstream
Projects
Status: Triage
Development

No branches or pull requests

2 participants