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

Added unit test for TaskNotFoundException #2533

Conversation

anandwana001
Copy link
Collaborator

@anandwana001 anandwana001 commented Jul 1, 2024

Comment on lines +27 to +34
class TaskNotFoundExceptionTest : BaseHiltTest() {

@Test
fun testCustomLocalizedMessage() {
val obj = Job.TaskNotFoundException(taskId = "1")
assertThat(obj.localizedMessage).isEqualTo("unknown task 1")
}
}
Copy link
Member

Choose a reason for hiding this comment

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

I don't feel we need a specific test class for the exception. Instead, we should look into how to add coverage for this class using user flows.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ok, this class was mentioned in the given test coverage list.

how to add coverage for this class using user flows.

I think an independent is useful to confirm whether the custom message is correct or not. No matter which user flow is uses.

Copy link
Member

Choose a reason for hiding this comment

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

The custom message is not user facing. @sufyanAbbasi Wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

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

My apologies on this, I did include this on the list because it showed up in the test coverage class list but it does look like something we can probably skip, since the code under test is a one-liner:

class TaskNotFoundException(taskId: String) : Throwable(message = "unknown task $taskId")

I will look into making sure that it can be removed from the test coverage class list. If I can do that, then we can go ahead and remove this one from the list. If that's not possible, we can keep the test in to satisfy the test coverage runner.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ok, IMO it's ok to have a test, no matter class is a one liner, just to save time in future and if the custom message is changed accidently, the test file will be our reminder.

Will close the PR as we are not planning to have it.

@sufyanAbbasi sufyanAbbasi self-requested a review July 1, 2024 19:25
@sufyanAbbasi
Copy link
Contributor

/gcbrun

@anandwana001
Copy link
Collaborator Author

/gcbrun

@sufyanAbbasi
Copy link
Contributor

/gcbrun

@gino-m
Copy link
Collaborator

gino-m commented Jul 19, 2024

/gcbrun

@sufyanAbbasi
Copy link
Contributor

/gcbrun

@shobhitagarwal1612 shobhitagarwal1612 merged commit 5c2f48b into google:master Jul 23, 2024
2 checks passed
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.

[Code health] Add Unit Test for TaskNotFoundException
4 participants