Use AssertJ’s exception assertions rather than fail

Closes gh-15761
This commit is contained in:
Andy Wilkinson
2019-02-04 11:48:14 +00:00
parent 9357a92503
commit 82bc87560c
26 changed files with 264 additions and 428 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,7 +27,7 @@ import org.springframework.boot.cli.command.grab.GrabCommand;
import org.springframework.util.FileSystemUtils;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
/**
* Integration tests for {@link GrabCommand}
@@ -64,14 +64,10 @@ public class GrabCommandIntegrationTests {
@Test
public void duplicateDependencyManagementBomAnnotationsProducesAnError() {
try {
this.cli.grab("duplicateDependencyManagementBom.groovy");
fail();
}
catch (Exception ex) {
assertThat(ex.getMessage())
.contains("Duplicate @DependencyManagementBom annotation");
}
assertThatExceptionOfType(Exception.class)
.isThrownBy(
() -> this.cli.grab("duplicateDependencyManagementBom.groovy"))
.withMessageContaining("Duplicate @DependencyManagementBom annotation");
}
@Test