Skip to content
This repository has been archived by the owner on Sep 19, 2024. It is now read-only.

Automated QA: Unit tests with other mocked infrastructure dependencies like logger, database, etc #635

Open
Tracked by #626
0x4007 opened this issue Aug 17, 2023 · 17 comments

Comments

@0x4007
Copy link
Member

0x4007 commented Aug 17, 2023

A lengthy goal would be to also include unit tests with mocked github events and other mocked infrastructure dependencies like logger, database, etc leading to the possibility of high coverage and test-driven development style.

Originally posted by @web4er in #626 (comment)

@kamaalsultan
Copy link
Contributor

kamaalsultan commented Aug 24, 2023

It would be good if someone hurries for this. I am not allowed.

@ubiquibot
Copy link

ubiquibot bot commented Aug 24, 2023

@ByteBallet The time limit for this bounty is on Fri, 25 Aug 2023 17:47:30 UTC

@0x4007
Copy link
Member Author

0x4007 commented Aug 24, 2023

I'll make an exception for tests. I think it will be fast to merge in because we don't need to really QA test it.

@kamaalsultan
Copy link
Contributor

kamaalsultan commented Aug 26, 2023

Since we migrated log from mezmo to supabase, supabase test is enough, isn't it?

@0x4007
Copy link
Member Author

0x4007 commented Aug 26, 2023

Not sure what that means but sounds like @0xcodercrane territory

@web4er
Copy link
Contributor

web4er commented Aug 27, 2023

I am looking forward to this.

Following are some points that I consider for high-quality unit tests.

  • must be fast to run for programmers to get a quick feedback
  • should be deterministic
  • unit tests must be isolated, one test should not depend on other
  • test behavior, not implementation
  • no heavy mocking. In a unit test, a unit is not necessarily a function or a class, it is a unit of requirements.

@0xcodercrane
Copy link
Contributor

Since we migrated log from mezmo to supabase, supabase test is enough, isn't it?

We've created an adapter for supabase so it's fine that have the unit tests for supabase adapter. no need for supabase-js itself

@0xcodercrane
Copy link
Contributor

no heavy mocking. In a unit test, a unit is not necessarily a function or a class, it is a unit of requirements.

What do you mean by unit of requirements? In my opinion, it should be either a function or class.

@ubiquibot
Copy link

ubiquibot bot commented Aug 30, 2023

Do you have any updates @ByteBallet? If you would like to release the bounty back to the DevPool, please comment /stop
Last activity time: Sat Aug 26 2023 07:08:04 GMT+0000 (Coordinated Universal Time)

@kamaalsultan
Copy link
Contributor

kamaalsultan commented Aug 30, 2023

Would it be okay to create another supbase db for testing?

@web4er
Copy link
Contributor

web4er commented Aug 30, 2023

What do you mean by unit of requirements? In my opinion, it should be either a function or class.

You are right. I see not-so-good wording used by me here. Basically, what I am trying to say is if a function or a class that is subject under test, is calling another function, do not mock that function.

Developers try to achieve test in isolation. Here, they try to isolate function or class which is the subject under test. This results in heavy mocking. Test in isolation is for the "test" not the "subject under tests".

But you can mock for one of 2 reasons:

  • it slows down test speed, e.g. http request
  • shared fixture where one test can affect another test e.g. file or db

@ubiquibot
Copy link

ubiquibot bot commented Sep 3, 2023

Do you have any updates @ByteBallet? If you would like to release the bounty back to the DevPool, please comment /stop
Last activity time: Wed Aug 30 2023 09:28:00 GMT+0000 (Coordinated Universal Time)

@kamaalsultan
Copy link
Contributor

Currently in progress.

@kamaalsultan
Copy link
Contributor

kamaalsultan commented Sep 4, 2023

We've created an adapter for supabase so it's fine that have the unit tests for supabase adapter. no need for supabase-js itself

In case using supabase adapter, isn't the database affected? or should I just assume that the test is not done for production db?

@kamaalsultan
Copy link
Contributor

/stop

@ubiquibot
Copy link

ubiquibot bot commented Sep 5, 2023

You have been unassigned from the bounty @ByteBallet

@0xcodercrane
Copy link
Contributor

We've created an adapter for supabase so it's fine that have the unit tests for supabase adapter. no need for supabase-js itself

In case using supabase adapter, isn't the database affected? or should I just assume that the test is not done for production db?

The database isn't affected.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants