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

Refactor tests to use assertEquals #913

Merged
merged 2 commits into from
Mar 13, 2023
Merged

Conversation

dturner
Copy link
Collaborator

@dturner dturner commented Mar 10, 2023

I've refactored TasksDaoTest to:

  • use assertEquals because it's easier to read and removes the dependency on Hamcrest
  • instantiate the database only once, then clear it before each test - should result in slightly faster test execution

Also did a very minor tidy up to AddEditTaskScreenTest to swap expected and actual values as they were the wrong way round.

private lateinit var database: ToDoDatabase
// using an in-memory database because the information stored here disappears when the
// process is killed
private val database = Room.inMemoryDatabaseBuilder(
Copy link
Contributor

Choose a reason for hiding this comment

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

We probs still want to do this in @Before and @After so results of prior tests in the same test suite don't affect new ones

Copy link
Collaborator Author

@dturner dturner Mar 13, 2023

Choose a reason for hiding this comment

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

How would tests affect previous tests if we're calling clearAllTables @Before each test?

@dturner dturner merged commit 42d65a6 into android:main Mar 13, 2023
@dturner dturner deleted the tidy-tests branch March 13, 2023 18:50
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.

3 participants