mercredi 15 janvier 2020

When building Maven, UTF-8 encoded tests written in Groovy using Testng are not executed

When I try to run UTF-8 encoded tests written in Groovy using Testng, then when they are built in Maven, they fail and output С? Р? С? Р? Р? Р? Р? Р? РёС? Р? С ? РєРёС? instead of Cyrilic, but at the same time locally these tests are processed without problems

If i use

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <argLine>-Dfile.encoding=UTF-8</argLine>
            </configuration>
            <goals>
                <goal>test</goal>
            </goals>

Tell me how to run tests with UTF-8 so that they are not skipped

This is my pom.xml

<parent>
    <artifactId>test</artifactId>
    <groupId>com.example.test</groupId>
    <version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<groupId>com.example.test.testng</groupId>
<artifactId>testng</artifactId>

<properties>
    <java.version>1.8</java.version>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <spring.framework>5.1.8.RELEASE</spring.framework>
    <jackson.version>2.9.9</jackson.version>
    <guava.version>28.0-jre</guava.version>
    <powermock.version>2.0.2</powermock.version>
    <powermock.api.mockito.version>1.7.4</powermock.api.mockito.version>
    <resources.path>${project.basedir}/src/main/resources</resources.path>
    <test.resources.path>${project.basedir}/src/test/resources</test.resources.path>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

</properties>

<pluginRepositories>
    <pluginRepository>
        <id>bintray</id>
        <name>Groovy Bintray</name>
        <url>https://dl.bintray.com/groovy/maven</url>
        <releases>
            <updatePolicy>never</updatePolicy>
        </releases>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </pluginRepository>
</pluginRepositories>

<dependencies>
    <dependency>
        <groupId>org.codehaus.groovy</groupId>
        <artifactId>groovy-all</artifactId>
        <!-- <version>2.4.17</version> -->
    </dependency>

    <dependency>
        <groupId>org.apache.openjpa</groupId>
        <artifactId>openjpa</artifactId>
    </dependency>

    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <!--             <version>2.8.5</version> -->
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <!-- <version>${spring.framework}</version> -->
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <!-- <version>${spring.framework}</version> -->
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jdbc</artifactId>
        <!-- <version>${spring.framework}</version> -->
    </dependency>

    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <!-- <version>${jackson.version}</version> -->
    </dependency>

    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-annotations</artifactId>
        <!-- <version>${jackson.version}</version> -->
    </dependency>

    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <!-- <version>${guava.version}</version> -->
    </dependency>

    <dependency>
        <groupId>com.mockrunner</groupId>
        <artifactId>mockrunner-jdbc</artifactId>
        <version>2.0.1</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.hamcrest</groupId>
        <artifactId>hamcrest-core</artifactId>
        <!-- <version>2.1</version> -->
    </dependency>
    <dependency>
        <groupId>org.powermock</groupId>
        <artifactId>powermock-api-mockito2</artifactId>


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

        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>net.bytebuddy</groupId>
        <artifactId>byte-buddy</artifactId>
        <version>1.10.2</version>
    </dependency>

    <dependency>
        <groupId>net.bytebuddy</groupId>
        <artifactId>byte-buddy-agent</artifactId>
        <version>1.10.2</version>
        <type>pom</type>
    </dependency>


    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <!-- <version>7.0.0</version> -->
        <scope>test</scope>

    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <!-- <version>1.7.25</version> -->
    </dependency>

    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-lang3</artifactId>
        <!-- <version>3.9</version> -->
    </dependency>

    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-text</artifactId>
        <version>1.3</version>
    </dependency>

    <dependency>
        <groupId>javax.validation</groupId>
        <artifactId>validation-api</artifactId>
        <version>2.0.1.Final</version>
    </dependency>

    <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <resources>
        <resource>
            <directory>${resources.path}</directory>
            <filtering>true</filtering>
        </resource>
        <resource>
            <directory>${test.resources.path}}</directory>
            <filtering>true</filtering>
        </resource>
    </resources>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <argLine>-Dfile.encoding=${project.build.sourceEncoding}</argLine>
            </configuration>
            <goals>
                <goal>test</goal>
            </goals>
        </plugin>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <!-- <version>3.8.0</version> -->
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
                <compilerId>groovy-eclipse-compiler</compilerId>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>org.codehaus.groovy</groupId>
                    <artifactId>groovy-eclipse-compiler</artifactId>
                    <version>2.9.2-01</version>
                </dependency>
                <dependency>
                    <groupId>org.codehaus.groovy</groupId>
                    <artifactId>groovy-eclipse-batch</artifactId>
                    <version>2.4.3-01</version>
                </dependency>
            </dependencies>
        </plugin>
    </plugins>
</build>

Aucun commentaire:

Enregistrer un commentaire