Coder Social home page Coder Social logo

java-lint-assert's Introduction

Pluggable linting utility for Java tests

License Build Status

The plugin for Java Gradle test task that reports presence of asserts in a test method body.

Features:

  1. Prints the number of assert calls in each test method to the console
  2. Excludes test methods annotated with @Ignore (JUnit4) or @Disabled (JUnit5) from linting
  3. Limits the lint to recursively search from a top level package (for ex. 'com.jpmorgan')
  4. Allows verbose output

Supported Testing Frameworks:

  • JUnit 4
  • JUnit 5

Supported build types:

  • Gradle 4.9 and above

Installation:

  1. git clone https://github.com/jpmorganchase/java-lint-assert.git
  2. run gradle clean build publish from the root of the project. This will
  • build core module
  • build plugin module
  • install core and plugin jars into your local maven repo and into build dir under the project root

To see the plugin in action, cd .\client and run gradle cleanTest test -i . You should see the summary table:

Package Test file name Test method name # asserts
org/lint PlaceholderTest.java dummy 0

Use:

Gradle:

In your build.gradle

I: add the java-lint-plugin dependency to the buildscript section:

buildscript {
   dependencies {
        classpath 'org.lint:plugin:0.1.0-SNAPSHOT'
    }
}

II: Add the plugin: apply plugin: org.lint.azzert.LintTestsPlugin

III: Configure lint:

test{
   ...   
    lintAssert{
        packageName = "org.lint" //optional or scan all
        verbose = true //optional, defaults to false
    }
}

IV: run your tests with -i on: gradle test -i

Future features:

  1. Exclude test classes annotated with @Ignore (JUnit4) and @Disabled (JUnit5) from linting
  2. Exclude tests annotated with @Expected (JUnit 4) and Assertions.assertThrows (JUnit 5) exception from linting
  3. Display results in alphabetic order of fully qualified test class name - org.lint.PlaceholderTest
  4. Print the linting summary: number of PASS/FAIL and a list of assertless tests
  5. Support a condensed output mode when only assertless tests are being printed
  6. Support 3 output modes info, warn, and error:
    • in warn mode, warn if linting found assertless tests
    • in error mode, fail the 'test' phase if linting found assertless tests
  7. Allow users to specify additional test frameworks
  8. When running in an IntelliJ console, make package.class.method "clickable" and navigate to the method declaration
  9. Display a ratio of # of asserts to the size of the "method under test" and number of its conditions
  10. Lint for assertness in nested test classes

License

The Apache 2.0 License). Please see License for more information.

java-lint-assert's People

Contributors

r2jp2zz avatar an-nadein avatar jpmjaw avatar

Watchers

James Cloos 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.