Ignore:
Timestamp:
2023-03-13T21:59:27+01:00 (13 months ago)
Author:
taylor.smock
Message:

See #16567: Convert all assertion calls to JUnit 5 (patch by gaben, modified)

The modifications are as follows:

  • Merge DomainValidatorTest.testIDN and DomainValidatorTest.testIDNJava6OrLater
  • Update some tests to use @ParameterizedTest (DomainValidatorTest)
  • Replace various exception blocks with assertThrows. These typically looked like
        try {
            // Something that should throw an exception here
            fail("An exception should have been thrown");
        } catch (Exception e) {
            // Verify the exception matches expectations here
        }
    
  • Replace assertTrue(val instanceof Clazz) with assertInstanceOf
  • Replace JUnit 4 @Suite with JUnit 5 @Suite

Both the original patch and the modified patch fix various lint issues.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/data/validation/tests/OpeningHourTestTest.java

    r18037 r18690  
    77import static org.hamcrest.MatcherAssert.assertThat;
    88import static org.junit.jupiter.api.Assertions.assertEquals;
     9import static org.junit.jupiter.api.Assertions.assertInstanceOf;
    910import static org.junit.jupiter.api.Assertions.assertNotNull;
    1011import static org.junit.jupiter.api.Assertions.assertTrue;
     
    258259    private static void assertFixEquals(String value, TestError error) {
    259260        assertNotNull(error.getFix(), "fix is not null");
    260         assertTrue(error.getFix() instanceof ChangePropertyCommand, "fix is ChangePropertyCommand");
    261         final ChangePropertyCommand command = (ChangePropertyCommand) error.getFix();
     261        final ChangePropertyCommand command = assertInstanceOf(ChangePropertyCommand.class, error.getFix(), "fix is ChangePropertyCommand");
    262262        assertEquals(1, command.getTags().size());
    263263        assertEquals(value, command.getTags().values().iterator().next());
Note: See TracChangeset for help on using the changeset viewer.