Comments (18)
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.
As a side note, the declaration of transactionManager = "transactionManager"
is superfluous since transactionManager
is the default name.
from spring-test-junit5.
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.
I just introduced a test exactly like you have described in 36b00d6.
- Test class: XmlSpringExtensionTests
- XML config: test-config.xml
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.
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.
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.
Sounds good. Thanks!
from spring-test-junit5.
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.
Another little question, how to force execution orders?
from spring-test-junit5.
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.
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.
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.
Closing this issue since the original poster has resolved the issue.
from spring-test-junit5.
Thanks for the support!
from spring-test-junit5.
You're welcome!
from spring-test-junit5.
Note added to README in 57aaa1f.
from spring-test-junit5.
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.
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)
- Better Spock integration with the changes for junit5? HOT 2
- Add info about https://jitpack.io to readme HOT 3
- beforeAll(ContainerExtensionContext context) not being overridden throwing AbstractMethodError in M5 HOT 3
- Upgrade to JUnit Jupiter 5.0.0-RC2 HOT 2
- Spring annotation should not be required in nested test class HOT 1
- SpringExtension speed up HOT 5
- No tests are run with junit-platform 1.2.0 and jupiter 5.2.0 HOT 5
- Create a new SpringExtension for Spring 3.2.x. HOT 1
- Artifacts seem to have disappeared from Maven Central HOT 1
- Disabling tests with SpEL HOT 3
- Spring-Enabled Extensions HOT 8
- Is it planned to upload this dependency to the maven central? HOT 1
- Support for nested tests HOT 3
- Create a new release HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spring-test-junit5.