Skip to content

Migrate to JUnit 5 asserts and assumes#286

Merged
garydgregory merged 1 commit intoapache:masterfrom
stevebosman:BEANUTILS-569-update-asserts-assumes
Sep 13, 2024
Merged

Migrate to JUnit 5 asserts and assumes#286
garydgregory merged 1 commit intoapache:masterfrom
stevebosman:BEANUTILS-569-update-asserts-assumes

Conversation

@stevebosman
Copy link
Contributor

Upgraded JUnit 4 asserts and assumes to JUnit 5.

@stevebosman stevebosman force-pushed the BEANUTILS-569-update-asserts-assumes branch from de86bc5 to ac39776 Compare September 13, 2024 08:32
@stevebosman stevebosman force-pushed the BEANUTILS-569-update-asserts-assumes branch from ac39776 to c8b26b7 Compare September 13, 2024 10:30
@stevebosman
Copy link
Contributor Author

I've added a quick fix in the pom as the tests were no longer running after the rename

Copy link
Member

@garydgregory garydgregory left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comments, for future contributions.

for (final PropertyDescriptor pd : beanInfo.getPropertyDescriptors()) {
if (pd.getName().equals("file")) {
Assume.assumeTrue("BEANUTILS-492: IndexedPropertyDescriptor no longer supported for java.util.List", pd instanceof IndexedPropertyDescriptor);
assumeTrue(pd instanceof IndexedPropertyDescriptor, "BEANUTILS-492: IndexedPropertyDescriptor no longer supported for java.util.List");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the future, you can use assertInstanceOf().

// despite being loaded via a classloader different from the one
// that loaded the Converter class.
assertTrue("Converter loader via child does not implement parent type", newFloatConverter instanceof Converter);
assertTrue(newFloatConverter instanceof Converter, "Converter loader via child does not implement parent type");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the future, you can use assertInstanceOf().

assertEquals("from String to URL", urlString, converter.convert(URL.class, urlString).toString());
assertEquals("from String to null type", urlString, converter.convert(null, urlString).toString());
assertEquals(urlString, converter.convert(URL.class, urlString).toString(), "from String to URL");
assertEquals(urlString, converter.convert(null, urlString).toString(),"from String to null type");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the future, make sure you have a space after a comma. I'll just reformat post merge.

@garydgregory garydgregory merged commit a0cdb3b into apache:master Sep 13, 2024
@stevebosman stevebosman deleted the BEANUTILS-569-update-asserts-assumes branch September 13, 2024 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants