Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forbid using Jupiter Kotlin assertions #5794

Merged
merged 2 commits into from
Feb 18, 2023
Merged

Conversation

TWiStErRob
Copy link
Member

Here are the imports that are relevant in this PR:

import org.junit.jupiter.api.fail
import org.junit.jupiter.api.assertAll
import org.junit.jupiter.api.assertThrows
import org.junit.jupiter.api.assertDoesNotThrow
import org.junit.jupiter.api.assertTimeout
import org.junit.jupiter.api.assertTimeoutPreemptively

and the signatures from org.junit.jupiter.api.AssertionsKt:

fun fail(message: String?, throwable: Throwable? = null): Nothing = TODO()
fun fail(message: (() -> String)?): Nothing = TODO()
fun fail(throwable: Throwable?): Nothing = TODO()
fun assertAll(vararg executables: () -> Unit): Nothing = TODO()
fun assertAll(heading: String?, vararg executables: () -> Unit): Nothing = TODO()
fun <reified T : Throwable> assertThrows(executable: () -> Unit): T = TODO()
fun <reified T : Throwable> assertThrows(message: String, executable: () -> Unit): T = TODO()
fun <reified T : Throwable> assertThrows(noinline message: () -> String, executable: () -> Unit): T =  TODO()
fun <R> assertDoesNotThrow(executable: () -> R): R = TODO()
fun <R> assertDoesNotThrow(message: String, executable: () -> R): R = TODO()
fun <R> assertDoesNotThrow(noinline message: () -> String, executable: () -> R): R = TODO()
fun <R> assertTimeout(timeout: Duration, executable: () -> R): R = TODO()
fun <R> assertTimeout(timeout: Duration, message: String, executable: () -> R): R = TODO()
fun <R> assertTimeout(timeout: Duration, message: () -> String, executable: () -> R): R = TODO()
fun <R> assertTimeoutPreemptively(timeout: Duration, executable: () -> R): R = TODO()
fun <R> assertTimeoutPreemptively(timeout: Duration, message: String, executable: () -> R): R = TODO()
fun <R> assertTimeoutPreemptively(timeout: Duration, message: () -> String, executable: () -> R): R = TODO()

Not all of them have AssertJ equivalent, but the ones who do are forbidden.

@codecov
Copy link

codecov bot commented Feb 18, 2023

Codecov Report

Merging #5794 (789f20b) into main (5cc94f4) will not change coverage.
The diff coverage is n/a.

@@            Coverage Diff            @@
##               main    #5794   +/-   ##
=========================================
  Coverage     84.54%   84.54%           
  Complexity     3744     3744           
=========================================
  Files           546      546           
  Lines         12780    12780           
  Branches       2229     2229           
=========================================
  Hits          10805    10805           
  Misses          861      861           
  Partials       1114     1114           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

This file already has assertThatCode usages.
@schalkms schalkms added this to the 1.23.0 milestone Feb 18, 2023
@schalkms schalkms merged commit 5938af0 into detekt:main Feb 18, 2023
@TWiStErRob TWiStErRob deleted the assertj branch May 19, 2023 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants