79135798

Date: 2024-10-29 04:03:40
Score: 1
Natty:
Report link

TL;DR: change the test struct to a class.

My source is from the Apple documentation on Swift Testing, which makes that suggestion here: "If teardown is needed, declare your test suite as a class or as an actor rather than as a structure and implement deinit".

Bonus: if you don't need inheritance, then adding final for compiler optimization is a good idea (see this Stackoverflow answer explaining why).

So, the only change I made was in my @Suite line doing just that.

Before:

@Suite("Single Quote View Model Tests") struct SingleQuoteViewModel_Tests {

After (Fixed):

@Suite("Single Quote View Model Tests") final class SingleQuoteViewModel_Tests {

Reasons:
  • Blacklisted phrase (1): Stackoverflow
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Daggerpov