Coder Social home page Coder Social logo

spring-test-junit5's Introduction

Spring JUnit 5 Testing Support

This project serves as the official prototype for JUnit 5 testing support in the Spring TestContext Framework which will eventually be incorporated into Spring Framework 5.0 in conjunction with SPR-13575.

Using the SpringExtension

Currently, all that's needed to use the Spring TestContext Framework with JUnit 5 is to annotate a JUnit 5 based test class with @ExtendWith(SpringExtension.class) and whatever Spring annotations you need (e.g., @ContextConfiguration, @Transactional, @Sql, etc.). See SpringExtensionTests for an example of this extension in action, and check out the source code of SpringExtension if you're interested in the implementation details.

Composing Annotations from Spring & JUnit

Spring has supported composed annotations for several years now, and as of JUnit 5 annotations in JUnit can also be used as meta-annotations. We can therefore create custom annotations that are composed from Spring annotations and JUnit 5 annotations. Take a look at @SpringJUnit5Config for an example, and check out ComposedSpringExtensionTests for an example of @SpringJUnit5Config in action.

License

This project is released under version 2.0 of the Apache License.

Artifacts

There are currently no downloadable artifacts for this project. However, if you install in a local Maven repository (see below) the generated artifact will correspond to the following.

  • Group ID: org.springframework.test
  • Artifact ID: spring-test-junit5
  • Version: 1.0.0.BUILD-SNAPSHOT

Building from Source

This project uses a Gradle-based build system. In the instructions below, ./gradlew is invoked from the root of the project and serves as a cross-platform, self-contained bootstrap mechanism for the build.

Prerequisites and Dependencies

Be sure that your JAVA_HOME environment variable points to the jdk1.8.0 folder extracted from the JDK download.

Compile and Test

Build all JARs, distribution ZIP files, and docs:

./gradlew build

Install spring-test-junit5 in local Maven repository

./gradlew install

Running Tests with Gradle

Executing gradlew clean test from the command line should result in output similar to the following.

:junit5Test

Test run finished after 1295 ms
[        24 tests found     ]
[         0 tests skipped   ]
[        24 tests started   ]
[         0 tests aborted   ]
[        24 tests successful]
[         0 tests failed    ]

Running Tests in the IDE

In order to execute the tests within an IDE, simply run SpringExtensionTestSuite as a JUnit 4 test class.


spring-test-junit5's People

Contributors

sbrannen avatar

Watchers

Jack Chen avatar

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.