From f6e05a12415616ae6430994733c277bbc7683e3d Mon Sep 17 00:00:00 2001 From: Adam Young Date: Tue, 17 Sep 2024 16:44:07 +0100 Subject: [PATCH] REFACTOR: Migrate Discover tests to Swift Testing --- .../Account/Sorts/FavouriteSortTests.swift | 12 +- .../Account/Sorts/WatchlistSortTests.swift | 12 +- .../Requests/DiscoverMoviesRequestTests.swift | 64 +++++---- .../DiscoverTVSeriesRequestTests.swift | 58 +++++--- .../Discover/Sorts/MovieSortTests.swift | 132 ++++++++---------- .../Discover/Sorts/TVSeriesSortTests.swift | 60 ++++---- .../Discover/TMDbDiscoverServiceTests.swift | 71 ++++------ Tests/TMDbTests/TestUtils/Tags.swift | 1 + 8 files changed, 210 insertions(+), 200 deletions(-) diff --git a/Tests/TMDbTests/Domain/Services/Account/Sorts/FavouriteSortTests.swift b/Tests/TMDbTests/Domain/Services/Account/Sorts/FavouriteSortTests.swift index adf1902e..b80a5def 100644 --- a/Tests/TMDbTests/Domain/Services/Account/Sorts/FavouriteSortTests.swift +++ b/Tests/TMDbTests/Domain/Services/Account/Sorts/FavouriteSortTests.swift @@ -26,17 +26,23 @@ struct FavouriteSortTests { @Test("createdAt default description is created_at.asc") func createdAtWhenDefaultReturnsDescription() { - #expect(FavouriteSort.createdAt().description == "created_at.asc") + let sort = FavouriteSort.createdAt() + + #expect(sort.description == "created_at.asc") } @Test("createdAt ascending description is created_at.asc") func createdAtWhenAscendingReturnsDescription() { - #expect(FavouriteSort.createdAt(descending: false).description == "created_at.asc") + let sort = FavouriteSort.createdAt(descending: false) + + #expect(sort.description == "created_at.asc") } @Test("createdAt descending description is created_at.desc") func createdAtWhenDescendingReturnsDescription() { - #expect(FavouriteSort.createdAt(descending: true).description == "created_at.desc") + let sort = FavouriteSort.createdAt(descending: true) + + #expect(sort.description == "created_at.desc") } } diff --git a/Tests/TMDbTests/Domain/Services/Account/Sorts/WatchlistSortTests.swift b/Tests/TMDbTests/Domain/Services/Account/Sorts/WatchlistSortTests.swift index 9d9fe7e2..9c9f5843 100644 --- a/Tests/TMDbTests/Domain/Services/Account/Sorts/WatchlistSortTests.swift +++ b/Tests/TMDbTests/Domain/Services/Account/Sorts/WatchlistSortTests.swift @@ -26,17 +26,23 @@ struct WatchlistSortTests { @Test("createdAt default description is created_at.asc") func createdAtWhenDefaultReturnsDescription() { - #expect(WatchlistSort.createdAt().description == "created_at.asc") + let sort = WatchlistSort.createdAt() + + #expect(sort.description == "created_at.asc") } @Test("createdAt ascending description is created_at.asc") func createdAtWhenAscendingReturnsDescription() { - #expect(WatchlistSort.createdAt(descending: false).description == "created_at.asc") + let sort = WatchlistSort.createdAt(descending: false) + + #expect(sort.description == "created_at.asc") } @Test("createdAt descending description is created_at.desc") func createdAtWhenDescendingReturnsDescription() { - #expect(WatchlistSort.createdAt(descending: true).description == "created_at.desc") + let sort = WatchlistSort.createdAt(descending: true) + + #expect(sort.description == "created_at.desc") } } diff --git a/Tests/TMDbTests/Domain/Services/Discover/Requests/DiscoverMoviesRequestTests.swift b/Tests/TMDbTests/Domain/Services/Discover/Requests/DiscoverMoviesRequestTests.swift index 79e3bb15..ec055a0a 100644 --- a/Tests/TMDbTests/Domain/Services/Discover/Requests/DiscoverMoviesRequestTests.swift +++ b/Tests/TMDbTests/Domain/Services/Discover/Requests/DiscoverMoviesRequestTests.swift @@ -17,48 +17,57 @@ // limitations under the License. // +import Foundation +import Testing @testable import TMDb -import XCTest -final class DiscoverMoviesRequestTests: XCTestCase { +@Suite(.tags(.requests, .discover)) +struct DiscoverMoviesRequestTests { - func testPath() { + @Test("path is correct") + func path() { let request = DiscoverMoviesRequest() - XCTAssertEqual(request.path, "/discover/movie") + #expect(request.path == "/discover/movie") } - func testQueryItemsIsEmpty() { + @Test("queryItems is empty") + func queryItemsIsEmpty() { let request = DiscoverMoviesRequest() - XCTAssertTrue(request.queryItems.isEmpty) + #expect(request.queryItems.isEmpty) } - func testQueryItemsWithPeople() { + @Test("queryItems with people") + func queryItemsWithPeople() { let request = DiscoverMoviesRequest(people: [1, 2, 3]) - XCTAssertEqual(request.queryItems, ["with_people": "1,2,3"]) + #expect(request.queryItems == ["with_people": "1,2,3"]) } - func testQueryItemsWithSortedBy() { + @Test("queryItems with sortedBy") + func queryItemsWithSortedBy() { let request = DiscoverMoviesRequest(sortedBy: .originalTitle(descending: false)) - XCTAssertEqual(request.queryItems, ["sort_by": "original_title.asc"]) + #expect(request.queryItems == ["sort_by": "original_title.asc"]) } - func testQueryItemsWithPage() { + @Test("queryItems with page") + func queryItemsWithPage() { let request = DiscoverMoviesRequest(page: 1) - XCTAssertEqual(request.queryItems, ["page": "1"]) + #expect(request.queryItems == ["page": "1"]) } - func testQueryItemsWithLanguage() { + @Test("queryItems with language") + func queryItemsWithLanguage() { let request = DiscoverMoviesRequest(language: "en") - XCTAssertEqual(request.queryItems, ["language": "en"]) + #expect(request.queryItems == ["language": "en"]) } - func testQueryItemsWithSortedByAndPeopleAndPageAndLanguage() { + @Test("queryItems with sortedBy, people, page and language") + func queryItemsWithSortedByAndPeopleAndPageAndLanguage() { let request = DiscoverMoviesRequest( people: [1, 2, 3], sortedBy: .originalTitle(descending: false), @@ -66,28 +75,33 @@ final class DiscoverMoviesRequestTests: XCTestCase { language: "en" ) - XCTAssertEqual( - request.queryItems, - ["sort_by": "original_title.asc", "with_people": "1,2,3", "page": "2", "language": "en"] - ) + #expect(request.queryItems == [ + "sort_by": "original_title.asc", + "with_people": "1,2,3", + "page": "2", + "language": "en" + ]) } - func testMethodIsGet() { + @Test("method is GET") + func methodIsGet() { let request = DiscoverMoviesRequest() - XCTAssertEqual(request.method, .get) + #expect(request.method == .get) } - func testHeadersIsEmpty() { + @Test("headers is empty") + func headersIsEmpty() { let request = DiscoverMoviesRequest() - XCTAssertTrue(request.headers.isEmpty) + #expect(request.headers.isEmpty) } - func testBodyIsNil() { + @Test("body is nil") + func bodyIsNil() { let request = DiscoverMoviesRequest() - XCTAssertNil(request.body) + #expect(request.body == nil) } } diff --git a/Tests/TMDbTests/Domain/Services/Discover/Requests/DiscoverTVSeriesRequestTests.swift b/Tests/TMDbTests/Domain/Services/Discover/Requests/DiscoverTVSeriesRequestTests.swift index b015b64b..0365b09d 100644 --- a/Tests/TMDbTests/Domain/Services/Discover/Requests/DiscoverTVSeriesRequestTests.swift +++ b/Tests/TMDbTests/Domain/Services/Discover/Requests/DiscoverTVSeriesRequestTests.swift @@ -17,70 +17,82 @@ // limitations under the License. // +import Foundation +import Testing @testable import TMDb -import XCTest -final class DiscoverTVSeriesRequestTests: XCTestCase { +@Suite(.tags(.requests, .discover)) +struct DiscoverTVSeriesRequestTests { - func testPath() { + @Test("path is correct") + func path() { let request = DiscoverTVSeriesRequest() - XCTAssertEqual(request.path, "/discover/tv") + #expect(request.path == "/discover/tv") } - func testQueryItemsIsEmpty() { + @Test("queryItems is empty") + func queryItemsIsEmpty() { let request = DiscoverTVSeriesRequest() - XCTAssertTrue(request.queryItems.isEmpty) + #expect(request.queryItems.isEmpty) } - func testQueryItemsWithSortedBy() { + @Test("queryItems with sortedBy") + func queryItemsWithSortedBy() { let request = DiscoverTVSeriesRequest(sortedBy: .firstAirDate(descending: false)) - XCTAssertEqual(request.queryItems, ["sort_by": "first_air_date.asc"]) + #expect(request.queryItems == ["sort_by": "first_air_date.asc"]) } - func testQueryItemsWithPage() throws { + @Test("queryItems with page") + func queryItemsWithPage() throws { let request = DiscoverTVSeriesRequest(page: 1) - XCTAssertEqual(request.queryItems, ["page": "1"]) + #expect(request.queryItems == ["page": "1"]) } - func testQueryItemsWithLanguage() { + @Test("queryItems with language") + func queryItemsWithLanguage() { let request = DiscoverMoviesRequest(language: "en") - XCTAssertEqual(request.queryItems, ["language": "en"]) + #expect(request.queryItems == ["language": "en"]) } - func testQueryItemsWithSortedByAndPageAndLanguage() { + @Test("queryItems with sortedBy, page and language") + func queryItemsWithSortedByAndPageAndLanguage() { let request = DiscoverTVSeriesRequest( sortedBy: .firstAirDate(descending: false), page: 2, language: "en" ) - XCTAssertEqual( - request.queryItems, - ["sort_by": "first_air_date.asc", "page": "2", "language": "en"] - ) + #expect(request.queryItems == [ + "sort_by": "first_air_date.asc", + "page": "2", + "language": "en" + ]) } - func testMethodIsGet() { + @Test("method is GET") + func methodIsGet() { let request = DiscoverTVSeriesRequest() - XCTAssertEqual(request.method, .get) + #expect(request.method == .get) } - func testHeadersIsEmpty() { + @Test("headers is empty") + func headersIsEmpty() { let request = DiscoverTVSeriesRequest() - XCTAssertTrue(request.headers.isEmpty) + #expect(request.headers.isEmpty) } - func testBodyIsNil() { + @Test("body is nil") + func bodyIsNil() { let request = DiscoverTVSeriesRequest() - XCTAssertNil(request.body) + #expect(request.body == nil) } } diff --git a/Tests/TMDbTests/Domain/Services/Discover/Sorts/MovieSortTests.swift b/Tests/TMDbTests/Domain/Services/Discover/Sorts/MovieSortTests.swift index 3dcee0fb..f7f905d6 100644 --- a/Tests/TMDbTests/Domain/Services/Discover/Sorts/MovieSortTests.swift +++ b/Tests/TMDbTests/Domain/Services/Discover/Sorts/MovieSortTests.swift @@ -17,121 +17,109 @@ // limitations under the License. // +import Foundation +import Testing @testable import TMDb -import XCTest -final class MovieSortTests: XCTestCase { +@Suite(.tags(.discover)) +struct MovieSortTests { - func testPopularityAscendingReturnsRawValue() { - let expectedResult = "popularity.asc" + @Test("popularity ascending description is popularity.asc") + func popularityAscendingReturnsRawValue() { + let sort = MovieSort.popularity(descending: false) - let result = MovieSort.popularity(descending: false).description - - XCTAssertEqual(result, expectedResult) + #expect(sort.description == "popularity.asc") } - func testPopularityDescendingReturnsRawValue() { - let expectedResult = "popularity.desc" - - let result = MovieSort.popularity(descending: true).description + @Test("popularity descending description is popularity.desc") + func popularityDescendingReturnsRawValue() { + let sort = MovieSort.popularity(descending: true) - XCTAssertEqual(result, expectedResult) + #expect(sort.description == "popularity.desc") } - func testReleaseDateAscendingReturnsRawValue() { - let expectedResult = "release_date.asc" + @Test("release date ascending description is release_date.asc") + func releaseDateAscendingReturnsRawValue() { + let sort = MovieSort.releaseDate(descending: false) - let result = MovieSort.releaseDate(descending: false).description - - XCTAssertEqual(result, expectedResult) + #expect(sort.description == "release_date.asc") } - func testReleaseDateDescendingReturnsRawValue() { - let expectedResult = "release_date.desc" - - let result = MovieSort.releaseDate(descending: true).description + @Test("release date descending description is release_date.desc") + func releaseDateDescendingReturnsRawValue() { + let sort = MovieSort.releaseDate(descending: true) - XCTAssertEqual(result, expectedResult) + #expect(sort.description == "release_date.desc") } - func testRevenueAscendingReturnsRawValue() { - let expectedResult = "revenue.asc" + @Test("revenue ascending description is revenue.asc") + func revenueAscendingReturnsRawValue() { + let sort = MovieSort.revenue(descending: false) - let result = MovieSort.revenue(descending: false).description - - XCTAssertEqual(result, expectedResult) + #expect(sort.description == "revenue.asc") } - func testRevenueDescendingReturnsRawValue() { - let expectedResult = "revenue.desc" - - let result = MovieSort.revenue(descending: true).description + @Test("revenue descending description is revenue.desc") + func revenueDescendingReturnsRawValue() { + let sort = MovieSort.revenue(descending: true) - XCTAssertEqual(result, expectedResult) + #expect(sort.description == "revenue.desc") } - func testPrimaryReleaseDateAscendingAscendingReturnsRawValue() { - let expectedResult = "primary_release_date.asc" - - let result = MovieSort.primaryReleaseDate(descending: false).description + @Test("primary release date ascending description is primary_release_date.asc") + func primaryReleaseDateAscendingAscendingReturnsRawValue() { + let sort = MovieSort.primaryReleaseDate(descending: false) - XCTAssertEqual(result, expectedResult) + #expect(sort.description == "primary_release_date.asc") } - func testPrimaryReleaseDateDescendingDescendingReturnsRawValue() { - let expectedResult = "primary_release_date.desc" + @Test("primary release date descending description is primary_release_date.desc") + func primaryReleaseDateDescendingDescendingReturnsRawValue() { + let sort = MovieSort.primaryReleaseDate(descending: true) - let result = MovieSort.primaryReleaseDate(descending: true).description - - XCTAssertEqual(result, expectedResult) + #expect(sort.description == "primary_release_date.desc") } - func testOriginalTitleAscendingReturnsRawValue() { - let expectedResult = "original_title.asc" - - let result = MovieSort.originalTitle(descending: false).description + @Test("original title ascending description is original_title.asc") + func originalTitleAscendingReturnsRawValue() { + let sort = MovieSort.originalTitle(descending: false) - XCTAssertEqual(result, expectedResult) + #expect(sort.description == "original_title.asc") } - func testOriginalTitleDescendingReturnsRawValue() { - let expectedResult = "original_title.desc" + @Test("original title descending description is original_title.desc") + func originalTitleDescendingReturnsRawValue() { + let sort = MovieSort.originalTitle(descending: true) - let result = MovieSort.originalTitle(descending: true).description - - XCTAssertEqual(result, expectedResult) + #expect(sort.description == "original_title.desc") } - func testVoteAverageAscendingReturnsRawValue() { - let expectedResult = "vote_average.asc" - - let result = MovieSort.voteAverage(descending: false).description + @Test("vote average ascending description is vote_average.asc") + func voteAverageAscendingReturnsRawValue() { + let sort = MovieSort.voteAverage(descending: false) - XCTAssertEqual(result, expectedResult) + #expect(sort.description == "vote_average.asc") } - func testVoteAverageDescendingReturnsRawValue() { - let expectedResult = "vote_average.desc" + @Test("vote average descending description is vote_average.desc") + func voteAverageDescendingReturnsRawValue() { + let sort = MovieSort.voteAverage(descending: true) - let result = MovieSort.voteAverage(descending: true).description - - XCTAssertEqual(result, expectedResult) + #expect(sort.description == "vote_average.desc") } - func testVoteCountAscendingReturnsRawValue() { - let expectedResult = "vote_count.asc" - - let result = MovieSort.voteCount(descending: false).description + @Test("vote count ascending description is vote_count.asc") + func voteCountAscendingReturnsRawValue() { + let sort = MovieSort.voteCount(descending: false) - XCTAssertEqual(result, expectedResult) + #expect(sort.description == "vote_count.asc") } - func testVoteCountDescendingReturnsRawValue() { - let expectedResult = "vote_count.desc" - - let result = MovieSort.voteCount(descending: true).description + @Test("vote count descending description is vote_count.desc") + func voteCountDescendingReturnsRawValue() { + let sort = MovieSort.voteCount(descending: true) - XCTAssertEqual(result, expectedResult) + #expect(sort.description == "vote_count.desc") } } diff --git a/Tests/TMDbTests/Domain/Services/Discover/Sorts/TVSeriesSortTests.swift b/Tests/TMDbTests/Domain/Services/Discover/Sorts/TVSeriesSortTests.swift index e6d9d783..efc667ba 100644 --- a/Tests/TMDbTests/Domain/Services/Discover/Sorts/TVSeriesSortTests.swift +++ b/Tests/TMDbTests/Domain/Services/Discover/Sorts/TVSeriesSortTests.swift @@ -17,57 +17,53 @@ // limitations under the License. // +import Foundation +import Testing @testable import TMDb -import XCTest -final class TVSeriesSortTests: XCTestCase { +@Suite(.tags(.discover)) +struct TVSeriesSortTests { - func testPopularityAscendingReturnsRawValue() { - let expectedResult = "popularity.asc" + @Test("popularity ascending description is popularity.asc") + func popularityAscendingReturnsRawValue() { + let sort = TVSeriesSort.popularity(descending: false) - let result = TVSeriesSort.popularity(descending: false).description - - XCTAssertEqual(result, expectedResult) + #expect(sort.description == "popularity.asc") } - func testPopularityDescendingReturnsRawValue() { - let expectedResult = "popularity.desc" - - let result = TVSeriesSort.popularity(descending: true).description + @Test("popularity descending description is popularity.desc") + func popularityDescendingReturnsRawValue() { + let sort = TVSeriesSort.popularity(descending: true) - XCTAssertEqual(result, expectedResult) + #expect(sort.description == "popularity.desc") } - func testFirstAirDateAscendingReturnsRawValue() { - let expectedResult = "first_air_date.asc" - - let result = TVSeriesSort.firstAirDate(descending: false).description + @Test("firstAirDate ascending description is first_air_date.asc") + func firstAirDateAscendingReturnsRawValue() { + let sort = TVSeriesSort.firstAirDate(descending: false) - XCTAssertEqual(result, expectedResult) + #expect(sort.description == "first_air_date.asc") } - func testFirstAirDateDescendingReturnsRawValue() { - let expectedResult = "first_air_date.desc" + @Test("firstAirDate descending description is first_air_date.desc") + func firstAirDateDescendingReturnsRawValue() { + let sort = TVSeriesSort.firstAirDate(descending: true) - let result = TVSeriesSort.firstAirDate(descending: true).description - - XCTAssertEqual(result, expectedResult) + #expect(sort.description == "first_air_date.desc") } - func testVoteAverageAscendingReturnsRawValue() { - let expectedResult = "vote_average.asc" - - let result = TVSeriesSort.voteAverage(descending: false).description + @Test("voteAverage ascending description is vote_average.asc") + func voteAverageAscendingReturnsRawValue() { + let sort = TVSeriesSort.voteAverage(descending: false) - XCTAssertEqual(result, expectedResult) + #expect(sort.description == "vote_average.asc") } - func testVoteAverageDescendingReturnsRawValue() { - let expectedResult = "vote_average.desc" - - let result = TVSeriesSort.voteAverage(descending: true).description + @Test("voteAverage descending description is vote_average.desc") + func voteAverageDescendingReturnsRawValue() { + let sort = TVSeriesSort.voteAverage(descending: true) - XCTAssertEqual(result, expectedResult) + #expect(sort.description == "vote_average.desc") } } diff --git a/Tests/TMDbTests/Domain/Services/Discover/TMDbDiscoverServiceTests.swift b/Tests/TMDbTests/Domain/Services/Discover/TMDbDiscoverServiceTests.swift index 52af3bb3..267e0f81 100644 --- a/Tests/TMDbTests/Domain/Services/Discover/TMDbDiscoverServiceTests.swift +++ b/Tests/TMDbTests/Domain/Services/Discover/TMDbDiscoverServiceTests.swift @@ -17,38 +17,35 @@ // limitations under the License. // +import Foundation +import Testing @testable import TMDb -import XCTest -final class TMDbDiscoverServiceTests: XCTestCase { +@Suite(.tags(.services, .configuration)) +struct TMDbDiscoverServiceTests { var service: TMDbDiscoverService! var apiClient: MockAPIClient! - override func setUp() { - super.setUp() - apiClient = MockAPIClient() - service = TMDbDiscoverService(apiClient: apiClient) + init() { + self.apiClient = MockAPIClient() + self.service = TMDbDiscoverService(apiClient: apiClient) } - override func tearDown() { - service = nil - apiClient = nil - super.tearDown() - } - - func testMoviesReturnsMovies() async throws { + @Test("movies returns movies") + func moviesReturnsMovies() async throws { let expectedResult = MoviePageableList.mock() apiClient.addResponse(.success(expectedResult)) let expectedRequest = DiscoverMoviesRequest(people: nil, sortedBy: nil, page: nil, language: nil) let result = try await service.movies() - XCTAssertEqual(result, expectedResult) - XCTAssertEqual(apiClient.lastRequest as? DiscoverMoviesRequest, expectedRequest) + #expect(result == expectedResult) + #expect(apiClient.lastRequest as? DiscoverMoviesRequest == expectedRequest) } - func testMoviesWithFilterAndSortByAndPageAndLanguageReturnsMovies() async throws { + @Test("movies with filter, sort by, page and language returns movies") + func moviesWithFilterAndSortByAndPageAndLanguageReturnsMovies() async throws { let people = [4, 5, 6, 7, 8] let sortBy = MovieSort.originalTitle(descending: false) let expectedResult = MoviePageableList.mock() @@ -60,37 +57,33 @@ final class TMDbDiscoverServiceTests: XCTestCase { let filter = DiscoverMovieFilter(people: people) let result = try await service.movies(filter: filter, sortedBy: sortBy, page: page, language: language) - XCTAssertEqual(result, expectedResult) - XCTAssertEqual(apiClient.lastRequest as? DiscoverMoviesRequest, expectedRequest) + #expect(result == expectedResult) + #expect(apiClient.lastRequest as? DiscoverMoviesRequest == expectedRequest) } - func testMoviesWhenErrorsThrowsError() async throws { + @Test("movies when errors throws error") + func moviesWhenErrorsThrowsError() async throws { apiClient.addResponse(.failure(.unknown)) - var error: Error? - do { + await #expect(throws: TMDbError.unknown) { _ = try await service.movies() - } catch let err { - error = err } - - let tmdbAPIError = try XCTUnwrap(error as? TMDbError) - - XCTAssertEqual(tmdbAPIError, .unknown) } - func testTVSeriesReturnsTVSeries() async throws { + @Test("tvSeries returns TV series") + func tvSeriesReturnsTVSeries() async throws { let expectedResult = TVSeriesPageableList.mock() apiClient.addResponse(.success(expectedResult)) let expectedRequest = DiscoverTVSeriesRequest(sortedBy: nil, page: nil, language: nil) let result = try await service.tvSeries() - XCTAssertEqual(result, expectedResult) - XCTAssertEqual(apiClient.lastRequest as? DiscoverTVSeriesRequest, expectedRequest) + #expect(result == expectedResult) + #expect(apiClient.lastRequest as? DiscoverTVSeriesRequest == expectedRequest) } - func testTVSeriesWithSortByAndPageAndLanguageReturnsTVSeries() async throws { + @Test("tvSeries with sort by, page and language returns TV series") + func tvSeriesWithSortByAndPageAndLanguageReturnsTVSeries() async throws { let sortBy = TVSeriesSort.firstAirDate(descending: false) let expectedResult = TVSeriesPageableList.mock() let page = expectedResult.page @@ -100,23 +93,17 @@ final class TMDbDiscoverServiceTests: XCTestCase { let result = try await service.tvSeries(sortedBy: sortBy, page: page, language: language) - XCTAssertEqual(result, expectedResult) - XCTAssertEqual(apiClient.lastRequest as? DiscoverTVSeriesRequest, expectedRequest) + #expect(result == expectedResult) + #expect(apiClient.lastRequest as? DiscoverTVSeriesRequest == expectedRequest) } - func testTVSeriesWhenErrorsThrowsError() async throws { + @Test("tvSeries when errors throws error") + func tvSeriesWhenErrorsThrowsError() async throws { apiClient.addResponse(.failure(.unknown)) - var error: Error? - do { + await #expect(throws: TMDbError.unknown) { _ = try await service.tvSeries() - } catch let err { - error = err } - - let tmdbAPIError = try XCTUnwrap(error as? TMDbError) - - XCTAssertEqual(tmdbAPIError, .unknown) } } diff --git a/Tests/TMDbTests/TestUtils/Tags.swift b/Tests/TMDbTests/TestUtils/Tags.swift index cb2bdc04..c1844f24 100644 --- a/Tests/TMDbTests/TestUtils/Tags.swift +++ b/Tests/TMDbTests/TestUtils/Tags.swift @@ -37,5 +37,6 @@ extension Tag { @Tag static var certification: Self @Tag static var company: Self @Tag static var configuration: Self + @Tag static var discover: Self }