GithubHelp home page GithubHelp logo

spencerwi / junit-displayname-generators Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 62 KB

A set of pre-baked @DisplayNameGenerator classes for use with JUnit 5.4 and above.

License: MIT License

Kotlin 27.11% Java 72.89%
java junit junit5 testing-tools jvm

junit-displayname-generators's Introduction

junit-displayname-generators

Build Status

JUnit 5.4 and above support specifying a @DisplayNameGenerator to "rewrite" your test function names into more
readable display names for output, like so:

@DisplayNameGenerator(DisplayNameGenerator.ReplaceUnderscores.class)
class FooTest {
    @Test
    void some_test_that_checks_foo_behavior() {
        // ...
    } 
    // test will display as "some test that checks foo behavior"
}

The ReplaceUnderscores one demonstrated above ships with JUnit 5.4.

However, a more common practice in Java is to use camelCase (sometimes combined with underscores) to denote word separators.

This repo is a small-footprint packaging of a couple of different @DisplayNameGenerator classes that nicely format methods written with these more common practices.

Included DisplayNameGenerators

@DisplayNameGenerator(UnCamelCase.Methods.class) will rewrite the test method names only, "uncamelizing" them ( so that someTestThatChecksFooBehavior becomes "some Test That Checks Foo Behavior").

@DisplayNameGenerator(UnCamelCase.All.class) will rewrite the test method names and class names, "uncamelizing" them ( so that someTestThatChecksFooBehavior becomes "some Test That Checks Foo Behavior").

@DisplayNameGenerator(ReplaceUnderscoresAndUnCamelCase.Methods.class) will rewrite the test method names only, "uncamelizing" them and replacing underscores with spaces (so that testFoo_WhenUserIsNotFound_Throws becomes "test Foo When User Is Not Logged In Throws").

@DisplayNameGenerator(ReplaceUnderscoresAndUnCamelCase.Methods.class) will rewrite the test method names and class names, "uncamelizing" them and replacing underscores with spaces (so that testFoo_WhenUserIsNotFound_Throws becomes "test Foo When User Is Not Logged In Throws").

Installation

It's published in Maven Central! So all you have to do is add this to your Maven pomfile's dependency section (or the equivalent for your build tool):

<dependency>
    <groupId>com.spencerwi</groupId>
    <artifactId>junit-displayname-generators</artifactId>
    <version>1.0.0</version>
</dependency>

junit-displayname-generators's People

Contributors

spencerwi avatar

Watchers

 avatar  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.