Skip to content

Give generated tests typed descriptions#18843

Closed
boyum wants to merge 2 commits into
angular:masterfrom
boyum:typed-generated-tests
Closed

Give generated tests typed descriptions#18843
boyum wants to merge 2 commits into
angular:masterfrom
boyum:typed-generated-tests

Conversation

@boyum
Copy link
Copy Markdown

@boyum boyum commented Sep 22, 2020

Whenever class names change, test descriptions often are overlooked, as IDE's won't change them automatically. By using Function#name, we can render the exact same strings without having to worry about changes elsewhere.

I'm a first time contributor and I most probably do things in the wrong order or in a non-angular style. Please feel free to correct me and to lead the way. ✨

This is a redo of #18835 to fix commit messages

boyum and others added 2 commits September 22, 2020 09:28
whenever class names change, test descriptions often are overlooked, as IDE's won't change them automatically. By using Function#name, we can render the exact same strings without having to worry about changes elsewhere
Copy link
Copy Markdown
Collaborator

@alan-agius4 alan-agius4 left a comment

Choose a reason for hiding this comment

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

Personally, I am not a big fan of this. I find that with this pattern it's makes it harder to find failling unit tests, but that is just my personal opinion.

@boyum
Copy link
Copy Markdown
Author

boyum commented Sep 22, 2020

Personally, I am not a big fan of this. I find that with this pattern it's makes it harder to find failling unit tests, but that is just my personal opinion.

@alan-agius4 I'm not sure if I understand you. Could you please elaborate why this would affect looking for the unit tests? Are you thinking about the case where devs search for describe('MyComponent to find the given test file?

@Rogier-blip
Copy link
Copy Markdown

The benefit I see to this approach is the following:

When you, for example, change the name of a component the test automatically gets changed as well. This makes refactoring easier. To @boyum point, also changing the name when you change the name of a class gets overlooked often. I have seen multiple projects where many class names and test names are out of sync.

@alan-agius4 To your point, it will still be easy to find failing tests. In the overview of the test run, you will see the same name of the failing test as you would see if the string value of the class was there. Besides that, if you do a search in your IDE for the failing test name you will still be able to find the test since the class name is still there there is just a .name after the class name.

I believe this is a high-value feature for the maintainability of the angular tests.

@dgp1130
Copy link
Copy Markdown
Collaborator

dgp1130 commented Oct 15, 2020

After discussion amongst the team, our consensus is to keep generating the string literal rather than a reference to the class name.

See #19026 (comment) for additional info.

@dgp1130 dgp1130 closed this Oct 15, 2020
@angular-automatic-lock-bot
Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Nov 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants