Skip to content
This repository was archived by the owner on Jul 10, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/main/asciidoc/releasenotes/1.10.0.adoc
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
ifndef::jqa-in-manual[== Version 1.10.0]
ifdef::jqa-in-manual[== JUnit Plugin 1.10.0]

* No changes in this version.
=== Updated concepts

* Added support for additional assert methods to concept `junit5:AssertMethod`.
** The concept now matches all methods in `org.junit.jupiter.api.Assertions` starting with `assert`, thus now supports `assertThrows` and `assertTimeout*`.
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/jqassistant-rules/junit5.xml
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@
(assertType:Type)-[:DECLARES]->(assertMethod)
WHERE
assertType.fqn = 'org.junit.jupiter.api.Assertions'
and assertMethod.signature =~ 'void assert.*'
and assertMethod.signature CONTAINS ' assert'
SET
assertMethod:Junit5:Assert
RETURN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.function.Executable;

import static com.buschmais.jqassistant.core.report.api.model.Result.Status.SUCCESS;
import static com.buschmais.jqassistant.plugin.java.test.matcher.MethodDescriptorMatcher.methodDescriptor;
Expand Down Expand Up @@ -447,7 +448,8 @@ public void assertMethod() throws Exception {
// Oliver B. Fischer, 2019-02-20
assertThat(methods.size()).isGreaterThanOrEqualTo(109);
assertThat(methods, hasItems(methodDescriptor(Assertions.class, "assertTrue", boolean.class),
methodDescriptor(Assertions.class, "assertTrue", boolean.class, String.class)));
methodDescriptor(Assertions.class, "assertTrue", boolean.class, String.class),
methodDescriptor(Assertions.class, "assertThrows", Class.class, Executable.class)));
store.commitTransaction();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;

import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

@Disabled("This is not an actual test")
Expand Down Expand Up @@ -44,7 +45,16 @@ public void testWithNestedAssertion() {
nestedAssertion();
}

@Test
public void assertWithNonVoidReturn() {
assertThrows(IllegalArgumentException.class, this::throwsException);
}

private void nestedAssertion() {
assertTrue(() -> 2 > 1, "Condition must be true");
}

private void throwsException() throws IllegalArgumentException {

}
}