Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

review: test: add test for SubstituionInsertAllNestedTypes #3998

Merged
merged 4 commits into from
Jun 22, 2021
Merged

review: test: add test for SubstituionInsertAllNestedTypes #3998

merged 4 commits into from
Jun 22, 2021

Conversation

Rohitesh-Kumar-Jain
Copy link
Contributor

#1818

Hi, I have added a new test for insertAllNestedFilelds method of the Substitution class, this test improves code coverage, mutation converge and test strength all from 0% to 100%.

Here's the report before improvement.

Screenshot 2021-06-21 at 5 12 48 PM

The exception added in this test, is able to kill the mutation but, probably isn't the strongest assertion, I wan't able to make it stronger.

@Rohitesh-Kumar-Jain
Copy link
Contributor Author

Link to #3967

Copy link
Collaborator

@slarse slarse left a comment

Choose a reason for hiding this comment

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

Looks good, I just have some minor comments on this one.

@Rohitesh-Kumar-Jain
Copy link
Contributor Author

@slarse I would be glad if you may have again have a look at the PR : )

Copy link
Collaborator

@slarse slarse left a comment

Choose a reason for hiding this comment

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

Looks good to me! Just had a minor note on the new assertion's layout. But I think this is fine to merge, if you want to fix anything up at a later time you can just come back here.


// assert
assertEquals(1, targetType.getNestedTypes().size());
assertEquals("nestedClass", targetType.getNestedType("nestedClass").getSimpleName());
Copy link
Collaborator

Choose a reason for hiding this comment

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

The new assertion strengthens the test case in the sense that it verifies that there's a nested type with name nestedClass, and that's what was requested. So I think this is fine now.

However, I just wanted to note that the layout of the assertion makes it look like a test for CtType.getNestedType(String). To be clear, it looks like the assertion verifies that getting a nested type by a given name returns a type with that name. It would be sufficient here to just verify that the returned type is non-null, due to the functionality of getNestedType.

Suggested change
assertEquals("nestedClass", targetType.getNestedType("nestedClass").getSimpleName());
assertNotNull(targetType.getNestedType("nestedClass"));

Personally, I would probably have written both assertions like this instead, so as not to have to query targetType multiple times.

        List<CtType<?>> nestedTypes = targetType.getNestedTypes();
        assertThat(nestedTypes.size(), equalTo(1));
        assertThat(nestedTypes.get(0), equalTo("nestedClass"));

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestions, so I can add this in the PR that I will raise for another new test?

@slarse slarse merged commit 075f91f into INRIA:master Jun 22, 2021
@Rohitesh-Kumar-Jain Rohitesh-Kumar-Jain deleted the add-test-for-substitution-insertallnestedtypes branch July 8, 2021 09:37
@monperrus monperrus mentioned this pull request Aug 19, 2021
woutersmeenk pushed a commit to woutersmeenk/spoon that referenced this pull request Aug 29, 2021
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