Skip to content

test(aspect migration mutator): Automated tests for implementations o…#16872

Open
gdatahub wants to merge 5 commits into
masterfrom
automated-test-aspect-PFP-2841
Open

test(aspect migration mutator): Automated tests for implementations o…#16872
gdatahub wants to merge 5 commits into
masterfrom
automated-test-aspect-PFP-2841

Conversation

@gdatahub
Copy link
Copy Markdown
Contributor

@gdatahub gdatahub commented Apr 1, 2026

…f Abstract AspectMigrationMutators

Automated tests for implementations of Abstract AspectMigrationMutators

Two approaches:

  1. Reflection-based (fully automatic): discovers all AspectMigrationMutator implementations and runs tests automatically.
  2. Template pattern-based (semi-automatic): uses a base test class as a template; each implementation must create a test class extending it.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 1, 2026

Bundle Report

Bundle size has no change ✅

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@BeforeMethod
public void setUp() {
entityRegistry = new TestEntityRegistry();
AspectRetriever mockRetriever = mock(AspectRetriever.class);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Will need this retriver mocks behaviour be customized by each subclass. Some of them may need to use the retriever to compute the transform.

Copy link
Copy Markdown
Contributor Author

@gdatahub gdatahub Apr 2, 2026

Choose a reason for hiding this comment

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

Good Point. Added a method configureRetrieverMock(@Nonnull AspectRetriever retrieverMock) that is invoked at the end of setUp(), this hook handles subclasses that need common retriever setup across all tests .

A subclass whose mutator calls
retrieverContext.getAspectRetriever().getLatestAspect(...) can override this and add stubs:

  @Override
  protected void configureRetrieverMock(AspectRetriever retrieverMock) {
      when(retrieverMock.getLatestAspect(any(), eq("ownership")))
          .thenReturn(someAspect);
  }

}

@Test
public void writeMutation_alreadyAtTargetVersion_isNoOp() {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this isnt really testing the mutator implementation -- this is pretty much the base class test, so doesnt need to run on each subclass. Same with a few other such methods. All we need to test here - is use sourceAspect and assertTransform with suitable retriever mocking (which is very mutator implementation specific). The retriever may be used by the mutator to fetch some other value in order to compute what the transform should be. Rest are really base class tests

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Made the following changes:

  • Removed writeMutation_alreadyAtTargetVersion_isNoOp, readMutation_alreadyAtTargetVersion_isNoOp, and writeMutation_futureVersion_isNoOp, as these base-class version-gating tests are already covered by AspectMigrationMutatorTest.
  • Added configureRetrieverMock(AspectRetriever) hook so subclasses can stub retriever behavior specific to their transform logic. mockRetriever is also exposed as a field for per-test verify() calls.
  • Kept contract_targetVersionIsSourceVersionPlusOne and contract_sourceVersionAtLeastDefault as lightweight checks to ensure each concrete implementation correctly declares its version numbers.

@alwaysmeticulous
Copy link
Copy Markdown

alwaysmeticulous Bot commented Apr 2, 2026

🔴 Meticulous spotted visual differences in 1 of 1181 screens tested: view and approve differences detected.

Meticulous evaluated ~6 hours of user flows against your PR.

Last updated for commit 1824601 test(aspect migration mutator): fixed compilation issue and added todo f.... This comment will update as new commits are pushed.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 2, 2026

Linear: PFP-3221

@github-actions
Copy link
Copy Markdown
Contributor

Your PR has been assigned to @chakru-r (chakru.racharla) for review (PFP-3221).

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