SlideShare uma empresa Scribd logo
1 de 42
from Lambda to Alpha and Beyond …
Sam Brannen
@sam_brannen
JUnit
2
Sam Brannen
• Spring and Java Consultant @
• Java Developer for over 17 years
• Spring Framework Core Committer since 2007
• Swiss Spring User Group Lead
• Trainer & Conference Speaker
• JUnit 5 Core Committer since October 2015
3
Swiftmind
Experts in Spring and Enterprise Java
Areas of expertise
• Spring *
• Java EE
• Software Architecture
• Software Development
Where you find us
• Zurich, Switzerland
• @swiftmind
• http://www.swiftmind.com
4
A Show of Hands…
5
Agenda
• Impetus for Change
• JUnit Lambda
• Roadmap
• JUnit 5
• Feedback
• Q&A
6
Impetus for Change
7
Why a New Version of JUnit?
• JUnit 4.0 was released a decade ago
– a lot has changed since then…
– testing needs have matured
– expectations have grown
• Modularity  big ball of mud
• Test discovery and execution  tightly coupled
• Extensibility  lot of room for improvement
• Let’s not forget Java 8
8
Modularity in JUnit 4
• Sure there are packages
– but… there’s only THE junit.jar
9
JUnit 4 Runner API
• Very powerful
• In fact, it can do anything
• But… you can’t combine Runners
• Parameterized + SpringJUnit4ClassRunner  no way
10
JUnit 4… Rules… are meant to be broken
• JUnit 4.7: MethodRule (@Rule)
• JUnit 4.9: TestRule (@Rule / @ClassRule)
• Great for simple use cases
• Can even be combined
• But… a single rule can’t be used for method-level and
class-level callbacks
• Plus… zero support for instance-level callbacks
• Case in point: SpringClassRule / SpringMethodRule
11
JUnit Lambda
12
Crowdfunding Campaign
• Initiated by Johannes Link and
Marc Philipp
• Later joined by Matthias Merdes,
Stefan Bechtold, & Sam Brannen
• Ran from July to October 2015
• Raised 53,937 Euros from 474
individuals and companies
• 4 companies donated 6 weeks of
developer time
13
Thanks!
14
The Kick-off Team
15
Roadmap
• Prototype  December 2nd, 2015
• 5.0.0-ALPHA  February 1st, 2016
• 5.0.0-M1  in progress
– tentative release end of June 2016
• M2, M3, …  Summer 2016
• RC1, RC2, ...  Fall 2016
• GA  late 2016
16
JUnit 5
17
JUnit 5… in a Nutshell
• Modular
• Extensible
• Modern
• Forward and backward compatible
– JUnit 5 supports JUnit 3.8 and JUnit 4
– Can be run with JUnit 4
• @RunWith(JUnit5.class)
18
Architecture
• Test code depends only on
the JUnit 5 API.
• IDEs and build tools
depend on the Launcher
and Engine APIs and can
execute tests independent
of the testing framework
in use.
19
Modules
• junit5-api
• junit-launcher
• junit-engine-api
• junit5-engine
• junit4-engine
• junit4-runner
• junit-commons
• junit-console
• junit-gradle
• surefire-junit5
20
Launcher API
• Used by IDEs and build tools to launch the framework
• Central API for discovering and executing tests via one or
more engines
• TestDiscoveryRequest
– selectors and filters
• Feedback provided via the TestExecutionListener API
21
TestEngine API
• Test engine discovers and executes tests
– for a particular programming model
• Automatic discovery via Java’s ServiceLoader mechanism
• JUnit5TestEngine
• JUnit4TestEngine
• Implement your own…
22
JUnit 5 Extension Model
org.junit.gen5.api.extensions  @ExtendWith(...)
• BeforeAllCallback
• BeforeEachCallback
• BeforeTestExecutionCallback
• AfterTestExecutionCallback
• AfterEachCallback
• AfterAllCallback
• ContainerExecutionCondition
• TestExecutionCondition
• TestInstancePostProcessor
• ParameterResolver
• TestExecutionExceptionHandler
23
JUnit 5 Programming Model
org.junit.gen5.api
• Annotations and meta-annotations
• Assertions and Assumptions
• Custom display names
• Visibility
• Tagging
• Conditional test execution
• Dependency injection for constructors and methods
• Lambda expressions and method references
• Interface default methods
• Nested test classes
24
Annotations
• @Test
• @BeforeAll / @AfterAll
• @BeforeEach / @AfterEach
• @DisplayName
• @Tag / @Tags
• @Disabled
• @Nested
25
Assertions
org.junit.gen5.api.Assertions
• Limited set of core assertions
– assertEquals(), assertNotNull(), etc.
– plus assertThrows() and expectThrows()
– and assertAll()
• Supplier<String>  for lazy failure message evaluation
– message is now the last parameter
• For more power, use AssertJ, Hamcrest, etc.
26
Assumptions
org.junit.gen5.api.Assumptions
• Limited set of core assumptions
– For aborting tests mid-flight
• assumeTrue() / assumeFalse()
– BooleanSupplier, Supplier<String>
• assumingThat( ? , () -> {} );
27
DEMO
28
Test Names
• Names default to test class or test method names
– characters limited based on Java syntax
• Custom display names  @DisplayName
– Can contain spaces, special chars, and even emoji 😱
29
Dependency Injection
• Extension Model meets Programming Model
• ParameterResolver extension
– resolves parameters for constructors or methods
• TestInfo: inject into constructor, @Test, @BeforeEach, etc.
– access display name, tags, class, method
• TestInfoParameterResolver
– eating our own dog food ;-)
• See also:
– TestReporter
– MockitoExtension
– SpringExtension
30
DEMO
31
Tagging
• Declare @Tag or @Tags on an interface, class, or method
@Tag("fast")
@Test
void myFastTest() {
}
32
Custom Tags
• Declare @Tag or @Tags as a meta-annotation
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Tag("fast")
@Test
public @interface FastTest {
}
@FastTest
void myFastTest() {
}
33
Conditional Test Execution
• Extension Model meets Programming Model
• ContainerExecutionCondition
• TestExecutionCondition
• @Disabled
• DisabledCondition
– eating our own dog food ;-)
• Deactivate via Launcher/System property
– junit.conditions.deactivate = org.junit.*
34
DEMO
35
Interface Default Methods
• Introduces the concept of a test interface
– Enables multiple inheritance in tests
– Kinda like testing traits
• @BeforeEach / @AfterEach
• @Test
• @Tag
• @ExtendWith
• See StringTests example in user guide
36
Nested Test Classes
• Enables logical, hierarchical grouping of test classes
– with shared initialization and state from outer classes
• Declare @Nested on non-static nested classes
– i.e., inner classes
• You can even combine nested classes and test interfaces
• See TestingAStack example in user guide
37
Spring Support for JUnit 5
• SpringExtension
– @ExtendWith(SpringExtension.class)
– https://github.com/sbrannen/spring-test-junit5
• Works with Spring Framework 4.3
• Already supports:
– Core Spring TestContext Framework features
– Constructor and method injection via @Autowired,
@Qualifier, @Value
• Fully integrated in Spring Framework 5.0
38
DEMO
39
In Closing…
40
What’s Missing?
• Official IDE and build integration
• Dynamic tests (M1)
– registered as lambdas, streams, collections, etc.
• Parameterized tests (M2)
• Scenario tests (M3)
• Parallel execution (?)
• …
41
Resources and Feedback Channels
• Project Homepage
– http://junit.org/junit5
• User Guide
– http://junit.org/junit5/docs/current/user-guide
• Javadoc
– https://junit.ci.cloudbees.com/job/JUnit5/javadoc
• GitHub
– https://github.com/junit-team/junit5
• Sample Projects
– https://github.com/junit-team/junit5-samples
• Twitter
– https://twitter.com/JUnitTeam
• Stack Overflow
– http://stackoverflow.com/tags/junit5
42
Q & A
Sam Brannen
@sam_brannen
www.slideshare.net/sbrannen
www.swiftmind.com

Mais conteúdo relacionado

Mais procurados

JUnit 5 - The Next Generation
JUnit 5 - The Next GenerationJUnit 5 - The Next Generation
JUnit 5 - The Next GenerationKostadin Golev
 
Integration Group - Robot Framework
Integration Group - Robot Framework Integration Group - Robot Framework
Integration Group - Robot Framework OpenDaylight
 
Cucumber questions
Cucumber questionsCucumber questions
Cucumber questionsShivaraj R
 
Selenium interview questions
Selenium interview questionsSelenium interview questions
Selenium interview questionsgirichinna27
 
Selenium interview-questions-freshers
Selenium interview-questions-freshersSelenium interview-questions-freshers
Selenium interview-questions-freshersNaga Mani
 
Robot framework Gowthami Goli
Robot framework Gowthami GoliRobot framework Gowthami Goli
Robot framework Gowthami GoliGowthami Buddi
 
Realtime selenium interview questions
Realtime selenium interview questionsRealtime selenium interview questions
Realtime selenium interview questionsKuldeep Pawar
 
Introduction to JUnit testing in OpenDaylight
Introduction to JUnit testing in OpenDaylightIntroduction to JUnit testing in OpenDaylight
Introduction to JUnit testing in OpenDaylightOpenDaylight
 
Integration Group - Lithium test strategy
Integration Group - Lithium test strategyIntegration Group - Lithium test strategy
Integration Group - Lithium test strategyOpenDaylight
 
Introduction to Robot Framework
Introduction to Robot FrameworkIntroduction to Robot Framework
Introduction to Robot FrameworkCarl Su
 
TestWorks Conf Robot framework - the unsung hero of test automation - Michael...
TestWorks Conf Robot framework - the unsung hero of test automation - Michael...TestWorks Conf Robot framework - the unsung hero of test automation - Michael...
TestWorks Conf Robot framework - the unsung hero of test automation - Michael...Xebia Nederland BV
 
Keyword Driven Testing
Keyword Driven TestingKeyword Driven Testing
Keyword Driven TestingMaveryx
 

Mais procurados (20)

JUnit 5 - The Next Generation
JUnit 5 - The Next GenerationJUnit 5 - The Next Generation
JUnit 5 - The Next Generation
 
Spring Test Framework
Spring Test FrameworkSpring Test Framework
Spring Test Framework
 
TDD - Unit Testing
TDD - Unit TestingTDD - Unit Testing
TDD - Unit Testing
 
Integration Group - Robot Framework
Integration Group - Robot Framework Integration Group - Robot Framework
Integration Group - Robot Framework
 
Cucumber questions
Cucumber questionsCucumber questions
Cucumber questions
 
Junit5 brujug
Junit5 brujugJunit5 brujug
Junit5 brujug
 
Selenium interview questions
Selenium interview questionsSelenium interview questions
Selenium interview questions
 
Selenium interview-questions-freshers
Selenium interview-questions-freshersSelenium interview-questions-freshers
Selenium interview-questions-freshers
 
Robot framework Gowthami Goli
Robot framework Gowthami GoliRobot framework Gowthami Goli
Robot framework Gowthami Goli
 
Realtime selenium interview questions
Realtime selenium interview questionsRealtime selenium interview questions
Realtime selenium interview questions
 
Introduction to JUnit testing in OpenDaylight
Introduction to JUnit testing in OpenDaylightIntroduction to JUnit testing in OpenDaylight
Introduction to JUnit testing in OpenDaylight
 
PL/SQL unit testing with Ruby
PL/SQL unit testing with RubyPL/SQL unit testing with Ruby
PL/SQL unit testing with Ruby
 
Python in Test automation
Python in Test automationPython in Test automation
Python in Test automation
 
JUnit 5
JUnit 5JUnit 5
JUnit 5
 
Integration Group - Lithium test strategy
Integration Group - Lithium test strategyIntegration Group - Lithium test strategy
Integration Group - Lithium test strategy
 
Introduction to Robot Framework
Introduction to Robot FrameworkIntroduction to Robot Framework
Introduction to Robot Framework
 
TestWorks Conf Robot framework - the unsung hero of test automation - Michael...
TestWorks Conf Robot framework - the unsung hero of test automation - Michael...TestWorks Conf Robot framework - the unsung hero of test automation - Michael...
TestWorks Conf Robot framework - the unsung hero of test automation - Michael...
 
Keyword Driven Testing
Keyword Driven TestingKeyword Driven Testing
Keyword Driven Testing
 
What is new in JUnit5
What is new in JUnit5What is new in JUnit5
What is new in JUnit5
 
Unit testing (eng)
Unit testing (eng)Unit testing (eng)
Unit testing (eng)
 

Destaque

JUnit 5 - The Next Generation of JUnit - Ted's Tool Time
JUnit 5 - The Next Generation of JUnit - Ted's Tool TimeJUnit 5 - The Next Generation of JUnit - Ted's Tool Time
JUnit 5 - The Next Generation of JUnit - Ted's Tool TimeTed Vinke
 
JUnit- A Unit Testing Framework
JUnit- A Unit Testing FrameworkJUnit- A Unit Testing Framework
JUnit- A Unit Testing FrameworkOnkar Deshpande
 
Restful web services with java
Restful web services with javaRestful web services with java
Restful web services with javaVinay Gopinath
 
05 junit
05 junit05 junit
05 junitmha4
 
Unit testing with Junit
Unit testing with JunitUnit testing with Junit
Unit testing with JunitValerio Maggio
 
Advanced junit and mockito
Advanced junit and mockitoAdvanced junit and mockito
Advanced junit and mockitoMathieu Carbou
 
Maruti Baleno Euro-NCAP result sheet
Maruti Baleno Euro-NCAP result sheetMaruti Baleno Euro-NCAP result sheet
Maruti Baleno Euro-NCAP result sheetRushLane
 
Developing RESTful WebServices using Jersey
Developing RESTful WebServices using JerseyDeveloping RESTful WebServices using Jersey
Developing RESTful WebServices using Jerseyb_kathir
 
Fast ALS-Based Matrix Factorization for Recommender Systems
Fast ALS-Based Matrix Factorization for Recommender SystemsFast ALS-Based Matrix Factorization for Recommender Systems
Fast ALS-Based Matrix Factorization for Recommender SystemsDavid Zibriczky
 
Unit Testing with JUnit4 by Ravikiran Janardhana
Unit Testing with JUnit4 by Ravikiran JanardhanaUnit Testing with JUnit4 by Ravikiran Janardhana
Unit Testing with JUnit4 by Ravikiran JanardhanaRavikiran J
 
Test Automation
Test AutomationTest Automation
Test AutomationTomas Riha
 
API Test Automation Tips and Tricks
API Test Automation Tips and TricksAPI Test Automation Tips and Tricks
API Test Automation Tips and Trickstesthive
 
็Hand-on Exercise: Java Web Services using Eclipse + Tomcat & NetBeans + Glas...
็Hand-on Exercise: Java Web Services using Eclipse + Tomcat & NetBeans + Glas...็Hand-on Exercise: Java Web Services using Eclipse + Tomcat & NetBeans + Glas...
็Hand-on Exercise: Java Web Services using Eclipse + Tomcat & NetBeans + Glas...IMC Institute
 
RESTful Web Services with JAX-RS
RESTful Web Services with JAX-RSRESTful Web Services with JAX-RS
RESTful Web Services with JAX-RSCarol McDonald
 

Destaque (20)

JUnit 5 - The Next Generation of JUnit - Ted's Tool Time
JUnit 5 - The Next Generation of JUnit - Ted's Tool TimeJUnit 5 - The Next Generation of JUnit - Ted's Tool Time
JUnit 5 - The Next Generation of JUnit - Ted's Tool Time
 
JUnit- A Unit Testing Framework
JUnit- A Unit Testing FrameworkJUnit- A Unit Testing Framework
JUnit- A Unit Testing Framework
 
Restful web services with java
Restful web services with javaRestful web services with java
Restful web services with java
 
05 junit
05 junit05 junit
05 junit
 
Unit testing with Junit
Unit testing with JunitUnit testing with Junit
Unit testing with Junit
 
JUNit Presentation
JUNit PresentationJUNit Presentation
JUNit Presentation
 
Advanced junit and mockito
Advanced junit and mockitoAdvanced junit and mockito
Advanced junit and mockito
 
Maruti Baleno Euro-NCAP result sheet
Maruti Baleno Euro-NCAP result sheetMaruti Baleno Euro-NCAP result sheet
Maruti Baleno Euro-NCAP result sheet
 
Developing RESTful WebServices using Jersey
Developing RESTful WebServices using JerseyDeveloping RESTful WebServices using Jersey
Developing RESTful WebServices using Jersey
 
Introduction to JUnit
Introduction to JUnitIntroduction to JUnit
Introduction to JUnit
 
Fast ALS-Based Matrix Factorization for Recommender Systems
Fast ALS-Based Matrix Factorization for Recommender SystemsFast ALS-Based Matrix Factorization for Recommender Systems
Fast ALS-Based Matrix Factorization for Recommender Systems
 
Unit Testing with JUnit4 by Ravikiran Janardhana
Unit Testing with JUnit4 by Ravikiran JanardhanaUnit Testing with JUnit4 by Ravikiran Janardhana
Unit Testing with JUnit4 by Ravikiran Janardhana
 
Junit
JunitJunit
Junit
 
Test Automation
Test AutomationTest Automation
Test Automation
 
Test Driven Development and JUnit
Test Driven Development and JUnitTest Driven Development and JUnit
Test Driven Development and JUnit
 
API Test Automation Tips and Tricks
API Test Automation Tips and TricksAPI Test Automation Tips and Tricks
API Test Automation Tips and Tricks
 
็Hand-on Exercise: Java Web Services using Eclipse + Tomcat & NetBeans + Glas...
็Hand-on Exercise: Java Web Services using Eclipse + Tomcat & NetBeans + Glas...็Hand-on Exercise: Java Web Services using Eclipse + Tomcat & NetBeans + Glas...
็Hand-on Exercise: Java Web Services using Eclipse + Tomcat & NetBeans + Glas...
 
Unit testing with JUnit
Unit testing with JUnitUnit testing with JUnit
Unit testing with JUnit
 
Selenium Webdriver
Selenium WebdriverSelenium Webdriver
Selenium Webdriver
 
RESTful Web Services with JAX-RS
RESTful Web Services with JAX-RSRESTful Web Services with JAX-RS
RESTful Web Services with JAX-RS
 

Semelhante a JUnit 5 - from Lambda to Alpha and beyond

JUnit 5 Slides: Next generation Framework for Testing
JUnit 5 Slides: Next generation Framework for TestingJUnit 5 Slides: Next generation Framework for Testing
JUnit 5 Slides: Next generation Framework for TestingSurinder Mehra
 
Testing with Spring: An Introduction
Testing with Spring: An IntroductionTesting with Spring: An Introduction
Testing with Spring: An IntroductionSam Brannen
 
Spring Framework 3.2 - What's New
Spring Framework 3.2 - What's NewSpring Framework 3.2 - What's New
Spring Framework 3.2 - What's NewSam Brannen
 
Testing Spring MVC and REST Web Applications
Testing Spring MVC and REST Web ApplicationsTesting Spring MVC and REST Web Applications
Testing Spring MVC and REST Web ApplicationsSam Brannen
 
Effective .NET Core Unit Testing with SQLite and Dapper
Effective .NET Core Unit Testing with SQLite and DapperEffective .NET Core Unit Testing with SQLite and Dapper
Effective .NET Core Unit Testing with SQLite and DapperMike Melusky
 
There's more to Ratpack than non-blocking
There's more to Ratpack than non-blockingThere's more to Ratpack than non-blocking
There's more to Ratpack than non-blockingMarcin Erdmann
 
Effective .NET Core Unit Testing with SQLite and Dapper
Effective .NET Core Unit Testing with SQLite and DapperEffective .NET Core Unit Testing with SQLite and Dapper
Effective .NET Core Unit Testing with SQLite and DapperMike Melusky
 
MIGRATION - PAIN OR GAIN?
MIGRATION - PAIN OR GAIN?MIGRATION - PAIN OR GAIN?
MIGRATION - PAIN OR GAIN?DrupalCamp Kyiv
 
Test planning and software's engineering
Test planning and software's engineeringTest planning and software's engineering
Test planning and software's engineeringMansiganeshJawale
 
Salesforce Continuous Integration with AutoRABIT
Salesforce Continuous Integration with AutoRABITSalesforce Continuous Integration with AutoRABIT
Salesforce Continuous Integration with AutoRABITVishnu Raju Datla
 
Context Driven Automation Gtac 2008
Context Driven Automation Gtac 2008Context Driven Automation Gtac 2008
Context Driven Automation Gtac 2008Pete Schneider
 
Agile Testing Introduction
Agile Testing IntroductionAgile Testing Introduction
Agile Testing IntroductionHai Tran Son
 
Nyenrode Masterclass 'DevOps unraveled' Apr 18, 2016
Nyenrode Masterclass 'DevOps unraveled' Apr 18, 2016Nyenrode Masterclass 'DevOps unraveled' Apr 18, 2016
Nyenrode Masterclass 'DevOps unraveled' Apr 18, 2016Inspectie van het Onderwijs
 
KrishnaToolComparisionPPT.pdf
KrishnaToolComparisionPPT.pdfKrishnaToolComparisionPPT.pdf
KrishnaToolComparisionPPT.pdfQA or the Highway
 
It's all about feedback - code review as a great tool in the agile toolbox
It's all about feedback - code review as a great tool in the agile toolboxIt's all about feedback - code review as a great tool in the agile toolbox
It's all about feedback - code review as a great tool in the agile toolboxStefan Lay
 
Gerrit + Jenkins = Continuous Delivery For Big Data
Gerrit + Jenkins = Continuous Delivery For Big DataGerrit + Jenkins = Continuous Delivery For Big Data
Gerrit + Jenkins = Continuous Delivery For Big DataStefano Galarraga
 
Parser Breakout Session
Parser Breakout SessionParser Breakout Session
Parser Breakout SessionZhipeng Huang
 

Semelhante a JUnit 5 - from Lambda to Alpha and beyond (20)

JUnit 5 Slides: Next generation Framework for Testing
JUnit 5 Slides: Next generation Framework for TestingJUnit 5 Slides: Next generation Framework for Testing
JUnit 5 Slides: Next generation Framework for Testing
 
Testing with Spring: An Introduction
Testing with Spring: An IntroductionTesting with Spring: An Introduction
Testing with Spring: An Introduction
 
Spring Framework 3.2 - What's New
Spring Framework 3.2 - What's NewSpring Framework 3.2 - What's New
Spring Framework 3.2 - What's New
 
Testing Spring MVC and REST Web Applications
Testing Spring MVC and REST Web ApplicationsTesting Spring MVC and REST Web Applications
Testing Spring MVC and REST Web Applications
 
Effective .NET Core Unit Testing with SQLite and Dapper
Effective .NET Core Unit Testing with SQLite and DapperEffective .NET Core Unit Testing with SQLite and Dapper
Effective .NET Core Unit Testing with SQLite and Dapper
 
There's more to Ratpack than non-blocking
There's more to Ratpack than non-blockingThere's more to Ratpack than non-blocking
There's more to Ratpack than non-blocking
 
Effective .NET Core Unit Testing with SQLite and Dapper
Effective .NET Core Unit Testing with SQLite and DapperEffective .NET Core Unit Testing with SQLite and Dapper
Effective .NET Core Unit Testing with SQLite and Dapper
 
MIGRATION - PAIN OR GAIN?
MIGRATION - PAIN OR GAIN?MIGRATION - PAIN OR GAIN?
MIGRATION - PAIN OR GAIN?
 
Automated testing 101
Automated testing 101Automated testing 101
Automated testing 101
 
Test planning and software's engineering
Test planning and software's engineeringTest planning and software's engineering
Test planning and software's engineering
 
Salesforce Continuous Integration with AutoRABIT
Salesforce Continuous Integration with AutoRABITSalesforce Continuous Integration with AutoRABIT
Salesforce Continuous Integration with AutoRABIT
 
Protractor survival guide
Protractor survival guideProtractor survival guide
Protractor survival guide
 
Context Driven Automation Gtac 2008
Context Driven Automation Gtac 2008Context Driven Automation Gtac 2008
Context Driven Automation Gtac 2008
 
Agile Testing Introduction
Agile Testing IntroductionAgile Testing Introduction
Agile Testing Introduction
 
Nyenrode Masterclass 'DevOps unraveled' Apr 18, 2016
Nyenrode Masterclass 'DevOps unraveled' Apr 18, 2016Nyenrode Masterclass 'DevOps unraveled' Apr 18, 2016
Nyenrode Masterclass 'DevOps unraveled' Apr 18, 2016
 
Design p atterns
Design p atternsDesign p atterns
Design p atterns
 
KrishnaToolComparisionPPT.pdf
KrishnaToolComparisionPPT.pdfKrishnaToolComparisionPPT.pdf
KrishnaToolComparisionPPT.pdf
 
It's all about feedback - code review as a great tool in the agile toolbox
It's all about feedback - code review as a great tool in the agile toolboxIt's all about feedback - code review as a great tool in the agile toolbox
It's all about feedback - code review as a great tool in the agile toolbox
 
Gerrit + Jenkins = Continuous Delivery For Big Data
Gerrit + Jenkins = Continuous Delivery For Big DataGerrit + Jenkins = Continuous Delivery For Big Data
Gerrit + Jenkins = Continuous Delivery For Big Data
 
Parser Breakout Session
Parser Breakout SessionParser Breakout Session
Parser Breakout Session
 

Mais de Sam Brannen

Testing with Spring, AOT, GraalVM, and JUnit 5 - Spring I/O 2023
Testing with Spring, AOT, GraalVM, and JUnit 5 - Spring I/O 2023Testing with Spring, AOT, GraalVM, and JUnit 5 - Spring I/O 2023
Testing with Spring, AOT, GraalVM, and JUnit 5 - Spring I/O 2023Sam Brannen
 
Testing with JUnit 5 and Spring - Spring I/O 2022
Testing with JUnit 5 and Spring - Spring I/O 2022Testing with JUnit 5 and Spring - Spring I/O 2022
Testing with JUnit 5 and Spring - Spring I/O 2022Sam Brannen
 
Get the Most out of Testing with Spring 4.2
Get the Most out of Testing with Spring 4.2Get the Most out of Testing with Spring 4.2
Get the Most out of Testing with Spring 4.2Sam Brannen
 
Composable Software Architecture with Spring
Composable Software Architecture with SpringComposable Software Architecture with Spring
Composable Software Architecture with SpringSam Brannen
 
Testing Web Apps with Spring Framework 3.2
Testing Web Apps with Spring Framework 3.2Testing Web Apps with Spring Framework 3.2
Testing Web Apps with Spring Framework 3.2Sam Brannen
 
Spring Framework 4.0 to 4.1
Spring Framework 4.0 to 4.1Spring Framework 4.0 to 4.1
Spring Framework 4.0 to 4.1Sam Brannen
 
Spring Framework 4.0 - The Next Generation - Soft-Shake 2013
Spring Framework 4.0 - The Next Generation - Soft-Shake 2013Spring Framework 4.0 - The Next Generation - Soft-Shake 2013
Spring Framework 4.0 - The Next Generation - Soft-Shake 2013Sam Brannen
 
Spring 3.1 and MVC Testing Support - 4Developers
Spring 3.1 and MVC Testing Support - 4DevelopersSpring 3.1 and MVC Testing Support - 4Developers
Spring 3.1 and MVC Testing Support - 4DevelopersSam Brannen
 
Effective out-of-container Integration Testing - 4Developers
Effective out-of-container Integration Testing - 4DevelopersEffective out-of-container Integration Testing - 4Developers
Effective out-of-container Integration Testing - 4DevelopersSam Brannen
 
Spring 3.1 to 3.2 in a Nutshell - SDC2012
Spring 3.1 to 3.2 in a Nutshell - SDC2012Spring 3.1 to 3.2 in a Nutshell - SDC2012
Spring 3.1 to 3.2 in a Nutshell - SDC2012Sam Brannen
 
Spring 3.1 to 3.2 in a Nutshell - Spring I/O 2012
Spring 3.1 to 3.2 in a Nutshell - Spring I/O 2012Spring 3.1 to 3.2 in a Nutshell - Spring I/O 2012
Spring 3.1 to 3.2 in a Nutshell - Spring I/O 2012Sam Brannen
 
Spring 3.1 and MVC Testing Support
Spring 3.1 and MVC Testing SupportSpring 3.1 and MVC Testing Support
Spring 3.1 and MVC Testing SupportSam Brannen
 
Spring 3.1 in a Nutshell - JAX London 2011
Spring 3.1 in a Nutshell - JAX London 2011Spring 3.1 in a Nutshell - JAX London 2011
Spring 3.1 in a Nutshell - JAX London 2011Sam Brannen
 
Spring 3.1 in a Nutshell
Spring 3.1 in a NutshellSpring 3.1 in a Nutshell
Spring 3.1 in a NutshellSam Brannen
 
Spring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSpring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSam Brannen
 
Effective out-of-container Integration Testing
Effective out-of-container Integration TestingEffective out-of-container Integration Testing
Effective out-of-container Integration TestingSam Brannen
 
What's New in Spring 3.0
What's New in Spring 3.0What's New in Spring 3.0
What's New in Spring 3.0Sam Brannen
 
Modular Web Applications with OSGi
Modular Web Applications with OSGiModular Web Applications with OSGi
Modular Web Applications with OSGiSam Brannen
 
Enterprise Applications With OSGi and SpringSource dm Server
Enterprise Applications With OSGi and SpringSource dm ServerEnterprise Applications With OSGi and SpringSource dm Server
Enterprise Applications With OSGi and SpringSource dm ServerSam Brannen
 

Mais de Sam Brannen (19)

Testing with Spring, AOT, GraalVM, and JUnit 5 - Spring I/O 2023
Testing with Spring, AOT, GraalVM, and JUnit 5 - Spring I/O 2023Testing with Spring, AOT, GraalVM, and JUnit 5 - Spring I/O 2023
Testing with Spring, AOT, GraalVM, and JUnit 5 - Spring I/O 2023
 
Testing with JUnit 5 and Spring - Spring I/O 2022
Testing with JUnit 5 and Spring - Spring I/O 2022Testing with JUnit 5 and Spring - Spring I/O 2022
Testing with JUnit 5 and Spring - Spring I/O 2022
 
Get the Most out of Testing with Spring 4.2
Get the Most out of Testing with Spring 4.2Get the Most out of Testing with Spring 4.2
Get the Most out of Testing with Spring 4.2
 
Composable Software Architecture with Spring
Composable Software Architecture with SpringComposable Software Architecture with Spring
Composable Software Architecture with Spring
 
Testing Web Apps with Spring Framework 3.2
Testing Web Apps with Spring Framework 3.2Testing Web Apps with Spring Framework 3.2
Testing Web Apps with Spring Framework 3.2
 
Spring Framework 4.0 to 4.1
Spring Framework 4.0 to 4.1Spring Framework 4.0 to 4.1
Spring Framework 4.0 to 4.1
 
Spring Framework 4.0 - The Next Generation - Soft-Shake 2013
Spring Framework 4.0 - The Next Generation - Soft-Shake 2013Spring Framework 4.0 - The Next Generation - Soft-Shake 2013
Spring Framework 4.0 - The Next Generation - Soft-Shake 2013
 
Spring 3.1 and MVC Testing Support - 4Developers
Spring 3.1 and MVC Testing Support - 4DevelopersSpring 3.1 and MVC Testing Support - 4Developers
Spring 3.1 and MVC Testing Support - 4Developers
 
Effective out-of-container Integration Testing - 4Developers
Effective out-of-container Integration Testing - 4DevelopersEffective out-of-container Integration Testing - 4Developers
Effective out-of-container Integration Testing - 4Developers
 
Spring 3.1 to 3.2 in a Nutshell - SDC2012
Spring 3.1 to 3.2 in a Nutshell - SDC2012Spring 3.1 to 3.2 in a Nutshell - SDC2012
Spring 3.1 to 3.2 in a Nutshell - SDC2012
 
Spring 3.1 to 3.2 in a Nutshell - Spring I/O 2012
Spring 3.1 to 3.2 in a Nutshell - Spring I/O 2012Spring 3.1 to 3.2 in a Nutshell - Spring I/O 2012
Spring 3.1 to 3.2 in a Nutshell - Spring I/O 2012
 
Spring 3.1 and MVC Testing Support
Spring 3.1 and MVC Testing SupportSpring 3.1 and MVC Testing Support
Spring 3.1 and MVC Testing Support
 
Spring 3.1 in a Nutshell - JAX London 2011
Spring 3.1 in a Nutshell - JAX London 2011Spring 3.1 in a Nutshell - JAX London 2011
Spring 3.1 in a Nutshell - JAX London 2011
 
Spring 3.1 in a Nutshell
Spring 3.1 in a NutshellSpring 3.1 in a Nutshell
Spring 3.1 in a Nutshell
 
Spring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSpring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. REST
 
Effective out-of-container Integration Testing
Effective out-of-container Integration TestingEffective out-of-container Integration Testing
Effective out-of-container Integration Testing
 
What's New in Spring 3.0
What's New in Spring 3.0What's New in Spring 3.0
What's New in Spring 3.0
 
Modular Web Applications with OSGi
Modular Web Applications with OSGiModular Web Applications with OSGi
Modular Web Applications with OSGi
 
Enterprise Applications With OSGi and SpringSource dm Server
Enterprise Applications With OSGi and SpringSource dm ServerEnterprise Applications With OSGi and SpringSource dm Server
Enterprise Applications With OSGi and SpringSource dm Server
 

Último

CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceanilsa9823
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 

Último (20)

CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 

JUnit 5 - from Lambda to Alpha and beyond

  • 1. from Lambda to Alpha and Beyond … Sam Brannen @sam_brannen JUnit
  • 2. 2 Sam Brannen • Spring and Java Consultant @ • Java Developer for over 17 years • Spring Framework Core Committer since 2007 • Swiss Spring User Group Lead • Trainer & Conference Speaker • JUnit 5 Core Committer since October 2015
  • 3. 3 Swiftmind Experts in Spring and Enterprise Java Areas of expertise • Spring * • Java EE • Software Architecture • Software Development Where you find us • Zurich, Switzerland • @swiftmind • http://www.swiftmind.com
  • 4. 4 A Show of Hands…
  • 5. 5 Agenda • Impetus for Change • JUnit Lambda • Roadmap • JUnit 5 • Feedback • Q&A
  • 7. 7 Why a New Version of JUnit? • JUnit 4.0 was released a decade ago – a lot has changed since then… – testing needs have matured – expectations have grown • Modularity  big ball of mud • Test discovery and execution  tightly coupled • Extensibility  lot of room for improvement • Let’s not forget Java 8
  • 8. 8 Modularity in JUnit 4 • Sure there are packages – but… there’s only THE junit.jar
  • 9. 9 JUnit 4 Runner API • Very powerful • In fact, it can do anything • But… you can’t combine Runners • Parameterized + SpringJUnit4ClassRunner  no way
  • 10. 10 JUnit 4… Rules… are meant to be broken • JUnit 4.7: MethodRule (@Rule) • JUnit 4.9: TestRule (@Rule / @ClassRule) • Great for simple use cases • Can even be combined • But… a single rule can’t be used for method-level and class-level callbacks • Plus… zero support for instance-level callbacks • Case in point: SpringClassRule / SpringMethodRule
  • 12. 12 Crowdfunding Campaign • Initiated by Johannes Link and Marc Philipp • Later joined by Matthias Merdes, Stefan Bechtold, & Sam Brannen • Ran from July to October 2015 • Raised 53,937 Euros from 474 individuals and companies • 4 companies donated 6 weeks of developer time
  • 15. 15 Roadmap • Prototype  December 2nd, 2015 • 5.0.0-ALPHA  February 1st, 2016 • 5.0.0-M1  in progress – tentative release end of June 2016 • M2, M3, …  Summer 2016 • RC1, RC2, ...  Fall 2016 • GA  late 2016
  • 17. 17 JUnit 5… in a Nutshell • Modular • Extensible • Modern • Forward and backward compatible – JUnit 5 supports JUnit 3.8 and JUnit 4 – Can be run with JUnit 4 • @RunWith(JUnit5.class)
  • 18. 18 Architecture • Test code depends only on the JUnit 5 API. • IDEs and build tools depend on the Launcher and Engine APIs and can execute tests independent of the testing framework in use.
  • 19. 19 Modules • junit5-api • junit-launcher • junit-engine-api • junit5-engine • junit4-engine • junit4-runner • junit-commons • junit-console • junit-gradle • surefire-junit5
  • 20. 20 Launcher API • Used by IDEs and build tools to launch the framework • Central API for discovering and executing tests via one or more engines • TestDiscoveryRequest – selectors and filters • Feedback provided via the TestExecutionListener API
  • 21. 21 TestEngine API • Test engine discovers and executes tests – for a particular programming model • Automatic discovery via Java’s ServiceLoader mechanism • JUnit5TestEngine • JUnit4TestEngine • Implement your own…
  • 22. 22 JUnit 5 Extension Model org.junit.gen5.api.extensions  @ExtendWith(...) • BeforeAllCallback • BeforeEachCallback • BeforeTestExecutionCallback • AfterTestExecutionCallback • AfterEachCallback • AfterAllCallback • ContainerExecutionCondition • TestExecutionCondition • TestInstancePostProcessor • ParameterResolver • TestExecutionExceptionHandler
  • 23. 23 JUnit 5 Programming Model org.junit.gen5.api • Annotations and meta-annotations • Assertions and Assumptions • Custom display names • Visibility • Tagging • Conditional test execution • Dependency injection for constructors and methods • Lambda expressions and method references • Interface default methods • Nested test classes
  • 24. 24 Annotations • @Test • @BeforeAll / @AfterAll • @BeforeEach / @AfterEach • @DisplayName • @Tag / @Tags • @Disabled • @Nested
  • 25. 25 Assertions org.junit.gen5.api.Assertions • Limited set of core assertions – assertEquals(), assertNotNull(), etc. – plus assertThrows() and expectThrows() – and assertAll() • Supplier<String>  for lazy failure message evaluation – message is now the last parameter • For more power, use AssertJ, Hamcrest, etc.
  • 26. 26 Assumptions org.junit.gen5.api.Assumptions • Limited set of core assumptions – For aborting tests mid-flight • assumeTrue() / assumeFalse() – BooleanSupplier, Supplier<String> • assumingThat( ? , () -> {} );
  • 28. 28 Test Names • Names default to test class or test method names – characters limited based on Java syntax • Custom display names  @DisplayName – Can contain spaces, special chars, and even emoji 😱
  • 29. 29 Dependency Injection • Extension Model meets Programming Model • ParameterResolver extension – resolves parameters for constructors or methods • TestInfo: inject into constructor, @Test, @BeforeEach, etc. – access display name, tags, class, method • TestInfoParameterResolver – eating our own dog food ;-) • See also: – TestReporter – MockitoExtension – SpringExtension
  • 31. 31 Tagging • Declare @Tag or @Tags on an interface, class, or method @Tag("fast") @Test void myFastTest() { }
  • 32. 32 Custom Tags • Declare @Tag or @Tags as a meta-annotation @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) @Tag("fast") @Test public @interface FastTest { } @FastTest void myFastTest() { }
  • 33. 33 Conditional Test Execution • Extension Model meets Programming Model • ContainerExecutionCondition • TestExecutionCondition • @Disabled • DisabledCondition – eating our own dog food ;-) • Deactivate via Launcher/System property – junit.conditions.deactivate = org.junit.*
  • 35. 35 Interface Default Methods • Introduces the concept of a test interface – Enables multiple inheritance in tests – Kinda like testing traits • @BeforeEach / @AfterEach • @Test • @Tag • @ExtendWith • See StringTests example in user guide
  • 36. 36 Nested Test Classes • Enables logical, hierarchical grouping of test classes – with shared initialization and state from outer classes • Declare @Nested on non-static nested classes – i.e., inner classes • You can even combine nested classes and test interfaces • See TestingAStack example in user guide
  • 37. 37 Spring Support for JUnit 5 • SpringExtension – @ExtendWith(SpringExtension.class) – https://github.com/sbrannen/spring-test-junit5 • Works with Spring Framework 4.3 • Already supports: – Core Spring TestContext Framework features – Constructor and method injection via @Autowired, @Qualifier, @Value • Fully integrated in Spring Framework 5.0
  • 40. 40 What’s Missing? • Official IDE and build integration • Dynamic tests (M1) – registered as lambdas, streams, collections, etc. • Parameterized tests (M2) • Scenario tests (M3) • Parallel execution (?) • …
  • 41. 41 Resources and Feedback Channels • Project Homepage – http://junit.org/junit5 • User Guide – http://junit.org/junit5/docs/current/user-guide • Javadoc – https://junit.ci.cloudbees.com/job/JUnit5/javadoc • GitHub – https://github.com/junit-team/junit5 • Sample Projects – https://github.com/junit-team/junit5-samples • Twitter – https://twitter.com/JUnitTeam • Stack Overflow – http://stackoverflow.com/tags/junit5
  • 42. 42 Q & A Sam Brannen @sam_brannen www.slideshare.net/sbrannen www.swiftmind.com