Skip to content

Conversation

@orpiske
Copy link
Contributor

@orpiske orpiske commented Jan 28, 2026

Add comprehensive test suite for the camel-console module:

  • Add AbstractDevConsoleTest base class with helper methods
  • Create SimpleDevConsoleTest parameterized test for 23 simple consoles
  • Create RouteBasedDevConsoleTest parameterized test for 8 route consoles
  • Add 16 new test files covering most DevConsole implementations
  • Add ~130 test methods testing both TEXT and JSON output formats
  • Add tests for Configurer classes (auto-generated property configurers)
  • Add camel-management as test dependency to enable JMX support
  • Coverage increased from ~9% to ~37%

Note: Some console classes (ProcessorDevConsole, ProducerDevConsole,
EventConsole) require full JMX MBean infrastructure that isn't easily
available in unit tests without significant setup. Further coverage
improvements would require integration tests with full JMX management.

Add comprehensive test suite for the camel-console module:
- Add AbstractDevConsoleTest base class with helper methods
- Create SimpleDevConsoleTest parameterized test for 23 simple consoles
- Create RouteBasedDevConsoleTest parameterized test for 8 route consoles
- Add 16 new test files covering most DevConsole implementations
- Add ~130 test methods testing both TEXT and JSON output formats
- Add tests for Configurer classes (auto-generated property configurers)
- Add camel-management as test dependency to enable JMX support
- Coverage increased from ~9% to ~37%

Note: Some console classes (ProcessorDevConsole, ProducerDevConsole,
EventConsole) require full JMX MBean infrastructure that isn't easily
available in unit tests without significant setup. Further coverage
improvements would require integration tests with full JMX management.
@github-actions
Copy link
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟

🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run

  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot.

  • You can label PRs using build-all, build-dependents, skip-tests and test-dependents to fine-tune the checks executed by this PR.

  • Build and test logs are available in the Summary page. Only Apache Camel committers have access to the summary.

  • ⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

*/
protected String callText(DevConsole console) {
String out = (String) console.call(DevConsole.MediaType.TEXT);
assertNotNull(out, "TEXT output should not be null");
Copy link
Contributor

@apupier apupier Jan 28, 2026

Choose a reason for hiding this comment

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

checking that it is not null is increasing coverage but it is not testing efficiently the expected output.
For instance, if it is a stacktracetrace which is returned because of an error, or if an empty string is provided, it won't be notice

it applies to a lot of places in the the PR

Comment on lines 48 to 50
Assertions.assertTrue(out.contains("myBean"));
Assertions.assertTrue(out.contains("anotherBean"));
Assertions.assertTrue(out.contains("TestBean"));
Copy link
Contributor

Choose a reason for hiding this comment

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

potential improvement: By using assertj Assertions.assertThat(out).containsAll("myBean", "anotherBean", "TestBean"), it gives a clearer error message in case of failure. it allows to see each text expected in a single time

StringReader reader = new StringReader("");

List<JsonObject> result = ConsoleHelper.loadSourceAsJson(reader, 1);
Assertions.assertNull(result);
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't it be better that it returns an empty list of null?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, probably a good improvement to do in ConsoleHelper in the future.

- Remove log.info() calls from test helper methods to avoid slowness
- Use AssertJ for clearer assertion error messages
- Use assertInstanceOf instead of assertTrue(x instanceof Y)
- Remove redundant assertNotNull before assertInstanceOf
- Remove null checks for expectedJsonKey in parameterized tests
- Use correct JSON keys that are always present in console output
@orpiske orpiske force-pushed the increase-coverage-console-tests branch from 50600c0 to 4344e5e Compare January 28, 2026 09:20
@orpiske orpiske merged commit 8c0781d into apache:main Jan 28, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants