It depends
If the fields are re-used elsewhere in the application, you might do better with enterUsername()
and enterPassword()
so you can call them for updating user data, changing user password, or forgot password scenarios.
If they're used only for logging in, you might find it simpler to just have an enterUserData()
method.
If you find that you're going to enter username and password in some places, and some variation on username or password, you might be better off using all three with enterUserData()
calling enterUsername()
and enterPassword()
.
It completely depends on what will work best with your application and how the fields are handled. What works well when every place you enter a username has a text field with the same ID and every place you enter a password has a password field with the same ID is not going to work the same when the username field is named differently on every page it appears.
As quite a few testers have said many times, there are no "best practices". There are only good practices which are more, or less, applicable to a specific situation.