Giter Site home page Giter Site logo

Comments (18)

sbrannen avatar sbrannen commented on August 19, 2024

Nothing has changed with regard to support for XML configuration files.

Thus, you must have configured something incorrectly.

Where does your testContext.xml file reside?

Is it in the root of your classpath (e.g., src/test/resources/testContext.xml)?

from spring-test-junit5.

sbrannen avatar sbrannen commented on August 19, 2024

As a side note, the declaration of transactionManager = "transactionManager" is superfluous since transactionManager is the default name.

from spring-test-junit5.

davideas avatar davideas commented on August 19, 2024

Thanks for the answer.
If I use @RunWith(SpringJUnit4ClassRunner.class) it works as usual, if I use @ExtendWith(SpringExtension.class) it doesn't initialize beans.

Yes it is in my classpath, I use the default folder structure and IDEA lint validations is ok with "classpath:testContext.xml", if I change it, it complains with Could not autowire. No beans of 'Service' type found.

+--main
|  +--java
|  +--resources
|  +--webapp
|  |  +--WEB-INF
|  |  |  +--applicationContext.xml
+--test
|  +--java
|  |  +--my.package
|  +--resources
|  |  +--testContext.xml

Maven test-compile produces:

+--target
|  +--my.package
|  +--testContext.xml

New maven dependencies for JUnit5:

<junit.jupiter.version>5.0.0-M2</junit.jupiter.version>
<junit.vintage.version>4.12.0-M2</junit.vintage.version>
<junit.platform.version>1.0.0-M2</junit.platform.version>
...
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.19.1</version>
    <dependencies>
        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-surefire-provider</artifactId>
            <version>${junit.platform.version}</version>
        </dependency>
    </dependencies>
</plugin>
...
<!-- JUnit -->
<dependency>
    <groupId>org.junit.jupiter</groupId>
    <artifactId>junit-jupiter-engine</artifactId>
    <version>${junit.jupiter.version}</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.junit.vintage</groupId>
    <artifactId>junit-vintage-engine</artifactId>
    <version>${junit.vintage.version}</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.springframework.test</groupId>
    <artifactId>spring-test-junit5</artifactId>
    <version>1.0.0.BUILD-SNAPSHOT</version>
    <scope>test</scope>
</dependency>

PS. Thanks for the side note

from spring-test-junit5.

sbrannen avatar sbrannen commented on August 19, 2024

I just introduced a test exactly like you have described in 36b00d6.

The above passes without any errors when using @RunWith(JUnitPlatform.class) within Eclipse and when using the JUnit Platform Gradle plugin within the Gradle build.

Thus, generally speaking, XML configuration is certainly supported.

from spring-test-junit5.

sbrannen avatar sbrannen commented on August 19, 2024

If you could create a simple project that reproduces the problem you're encountering (e.g., in a public Git repository), I would be happy to look into it.

from spring-test-junit5.

davideas avatar davideas commented on August 19, 2024

Thanks Sam, ok during next week I will try to prepare it, so I can also test it separately from my project.

from spring-test-junit5.

sbrannen avatar sbrannen commented on August 19, 2024

Sounds good. Thanks!

from spring-test-junit5.

davideas avatar davideas commented on August 19, 2024

Sam, thanks to your new test, I was able to check better your code and the problem is that I have old junit-4.12.jar in the classpath even if I've removed from maven dependencies (I don't know why it is still present) AND the existing imports were still present:

import org.junit.Before;
import org.junit.Test;

I couldn't be aware of them because it compiles as it should be, but they don't work with JUnit5, so we have to import:

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

Maybe you can specify this in your README to remind us that we need to be sure to use Annotations from the new org.junit.jupiter.api.* classes especially if we come from the old version.

from spring-test-junit5.

davideas avatar davideas commented on August 19, 2024

Another little question, how to force execution orders?

from spring-test-junit5.

sbrannen avatar sbrannen commented on August 19, 2024

Sam, thanks to your new test, I was able to check better your code and the problem is that I have old junit-4.12.jar in the classpath even if I've removed from maven dependencies (I don't know why it is still present) AND the existing imports were still present:

junit-4.12.jar is brought in as a transitive dependency via junit-vintage-engine. So if you're not using JUnit 3 or JUnit 4, you can safely remove the junit-vintage-engine dependency.

from spring-test-junit5.

sbrannen avatar sbrannen commented on August 19, 2024

Another little question, how to force execution orders?

As of JUnit 5.0 M2, there is no support yet for controlling the order in which tests in JUnit Jupiter are executed. See the following issues for details:

from spring-test-junit5.

sbrannen avatar sbrannen commented on August 19, 2024

Maybe you can specify this in your Readme to remind us that we need to be sure to use Annotations from the new org.junit.jupiter.api.* classes especially if we come from the old version.

Sure, I can add a note on that.

from spring-test-junit5.

sbrannen avatar sbrannen commented on August 19, 2024

Closing this issue since the original poster has resolved the issue.

from spring-test-junit5.

davideas avatar davideas commented on August 19, 2024

Thanks for the support!

from spring-test-junit5.

sbrannen avatar sbrannen commented on August 19, 2024

You're welcome!

from spring-test-junit5.

sbrannen avatar sbrannen commented on August 19, 2024

Note added to README in 57aaa1f.

from spring-test-junit5.

davideas avatar davideas commented on August 19, 2024

I write here for another thing:
SpringExtensionTestSuite.java (class is in your project) should execute all tests? why it says:

INFORMAZIONI: Discovered TestEngines with IDs: [junit-jupiter, junit-vintage]
Empty test suite.
Empty test suite.

Indeed I also have empty suite:

@RunWith(JUnitPlatform.class)
@IncludeEngines("junit-jupiter")
@SelectPackages("eu.davidea.tamarindo")
public class AllTests {
}

from spring-test-junit5.

sbrannen avatar sbrannen commented on August 19, 2024

Your last question is not related to the SpringExtension, so please ask a question under the junit5 tag on Stack Overflow: http://stackoverflow.com/tags/junit5

from spring-test-junit5.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.