koog
koog copied to clipboard
Refactor Prompt Tests
Changes Made
- Created a new abstract base class
AbstractPromptTestthat contains shared test fields, constants, and data providers - Extracted serialization-specific tests into a new
PromptSerializationTestclass - Updated the original
PromptTestclass to contain only non-serialization tests - Both test classes now extend the abstract base class to reuse common test infrastructure
- Replaced all JUnit assertions (assertEquals, assertTrue, assertNull) with their Kotest equivalents (shouldBe, shouldBeTrue, shouldBeNull) for improved readability
- Added
shouldBeEqualToComparingFieldsfor serialization tests to make sure all fields are verified. Remove unnecessary explicit assertions. - Implemented
assertSoftly(subject) { ... }for multiple assertions on the same subject - Added
withCluefor non-obvious assertions to provide better context for failures
Motivation
This refactoring improves the test organization by:
- Separating concerns: Serialization tests are now isolated from other prompt functionality tests
- Reducing code duplication: Common test setup and data providers are now in a shared abstract class
- Improving maintainability: Each test class has a clear, focused responsibility
- Making tests more readable: Smaller, more focused test classes are easier to understand
- Enhancing test failure messages: Kotest assertions provide more informative error messages
- Grouping related assertions: Using
assertSoftlyto see all failures at once rather than stopping at the first failure
Type of the change
- [ ] New feature
- [ ] Bug fix
- [ ] Documentation fix
- [x] Tests improvement
Checklist for all pull requests
- [x] The pull request has a description of the proposed change
- [x] I read the Contributing Guidelines before opening the pull request
- [x] The pull request uses
developas the base branch - [ ] Tests for the changes have been added
- [x] All new and existing tests passed
Additional steps for pull requests adding a new feature
- [ ] An issue describing the proposed change exists
- [ ] The pull request includes a link to the issue
- [ ] The change was discussed and approved in the issue
- [ ] Docs have been added / updated
Updated the original PromptTest class to contain only non-serialization tests
Was it reverted? I don't see it in the changelist.