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

test: Setting VIP 테스트코드 작성, 실패 메시지 문구 반대로 작성된 것 수정 #322

Merged
merged 7 commits into from
Dec 13, 2023
24 changes: 24 additions & 0 deletions iOS/Layover/Layover.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@
19A1694D2B18327E00DB34C0 /* sample.jpeg in Resources */ = {isa = PBXBuildFile; fileRef = 19A1694C2B18327E00DB34C0 /* sample.jpeg */; };
19AACFCA2B0F7C3B0088143E /* Response.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19AACFC92B0F7C3B0088143E /* Response.swift */; };
19AACFCC2B0F7D730088143E /* LoginDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19AACFCB2B0F7D730088143E /* LoginDTO.swift */; };
19AE48172B28C2B700DD4612 /* SettingViewControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19AE48132B28C2B700DD4612 /* SettingViewControllerTests.swift */; };
19AE48182B28C2B700DD4612 /* SettingInteractorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19AE48142B28C2B700DD4612 /* SettingInteractorTests.swift */; };
19AE481A2B28C2B700DD4612 /* SettingPresenterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19AE48162B28C2B700DD4612 /* SettingPresenterTests.swift */; };
19AE481C2B28C53800DD4612 /* MockSettingWorker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19AE481B2B28C53800DD4612 /* MockSettingWorker.swift */; };
19C7AFCE2B02410F003B35F2 /* AuthManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19C7AFCD2B02410F003B35F2 /* AuthManager.swift */; };
19C7AFD62B02584D003B35F2 /* KeychainStored.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19C7AFD52B02584D003B35F2 /* KeychainStored.swift */; };
19E79AC02B0A85D0009EA9ED /* LoopingPlayerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19E79ABF2B0A85D0009EA9ED /* LoopingPlayerView.swift */; };
Expand Down Expand Up @@ -341,6 +345,10 @@
19AACFC52B0F71DF0088143E /* Secrets.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Secrets.xcconfig; sourceTree = "<group>"; };
19AACFC92B0F7C3B0088143E /* Response.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Response.swift; sourceTree = "<group>"; };
19AACFCB2B0F7D730088143E /* LoginDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginDTO.swift; sourceTree = "<group>"; };
19AE48132B28C2B700DD4612 /* SettingViewControllerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingViewControllerTests.swift; sourceTree = "<group>"; };
19AE48142B28C2B700DD4612 /* SettingInteractorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingInteractorTests.swift; sourceTree = "<group>"; };
19AE48162B28C2B700DD4612 /* SettingPresenterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingPresenterTests.swift; sourceTree = "<group>"; };
19AE481B2B28C53800DD4612 /* MockSettingWorker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockSettingWorker.swift; sourceTree = "<group>"; };
19C7AFCD2B02410F003B35F2 /* AuthManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthManager.swift; sourceTree = "<group>"; };
19C7AFD52B02584D003B35F2 /* KeychainStored.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeychainStored.swift; sourceTree = "<group>"; };
19E79ABF2B0A85D0009EA9ED /* LoopingPlayerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoopingPlayerView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -583,6 +591,7 @@
194C21C72B1DF09B00C62645 /* Scenes */ = {
isa = PBXGroup;
children = (
19AE48122B28C2A800DD4612 /* Setting */,
192513632B26F7BB001533FA /* TagPlayList */,
1925137B2B277CC4001533FA /* Profile */,
194C21BE2B1DEE5500C62645 /* Home */,
Expand All @@ -605,6 +614,7 @@
194C21CB2B1DF39200C62645 /* MockHomeWorker.swift */,
1925136C2B26F84E001533FA /* MockTagPlayListWorker.swift */,
192513842B27852C001533FA /* MockUserWorker.swift */,
19AE481B2B28C53800DD4612 /* MockSettingWorker.swift */,
);
path = Workers;
sourceTree = "<group>";
Expand Down Expand Up @@ -722,6 +732,16 @@
path = DTOs;
sourceTree = "<group>";
};
19AE48122B28C2A800DD4612 /* Setting */ = {
isa = PBXGroup;
children = (
19AE48132B28C2B700DD4612 /* SettingViewControllerTests.swift */,
19AE48142B28C2B700DD4612 /* SettingInteractorTests.swift */,
19AE48162B28C2B700DD4612 /* SettingPresenterTests.swift */,
);
path = Setting;
sourceTree = "<group>";
};
19BB8A572B07BEE30070B922 /* UIComponents */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -1477,12 +1497,16 @@
1925136B2B26F7CE001533FA /* TagPlayListPresenterTests.swift in Sources */,
192513682B26F7CE001533FA /* TagPlayListViewControllerTests.swift in Sources */,
1925136A2B26F7CE001533FA /* TagPlayListWorkerTests.swift in Sources */,
19AE48182B28C2B700DD4612 /* SettingInteractorTests.swift in Sources */,
192513A72B278BB3001533FA /* Seeds.swift in Sources */,
194C21C52B1DEE6B00C62645 /* HomeWorkerTests.swift in Sources */,
19AE481C2B28C53800DD4612 /* MockSettingWorker.swift in Sources */,
192513802B277CD7001533FA /* ProfileViewControllerTests.swift in Sources */,
194C21C62B1DEE6B00C62645 /* HomePresenterTests.swift in Sources */,
1925137A2B273D98001533FA /* StubAuthManager.swift in Sources */,
1925136D2B26F84E001533FA /* MockTagPlayListWorker.swift in Sources */,
19AE481A2B28C2B700DD4612 /* SettingPresenterTests.swift in Sources */,
19AE48172B28C2B700DD4612 /* SettingViewControllerTests.swift in Sources */,
194C21C32B1DEE6B00C62645 /* HomeViewControllerTests.swift in Sources */,
192513692B26F7CE001533FA /* TagPlayListInteractorTests.swift in Sources */,
194C21CC2B1DF39200C62645 /* MockHomeWorker.swift in Sources */,
Expand Down
8 changes: 1 addition & 7 deletions iOS/Layover/Layover/Scenes/Setting/SettingWorker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,7 @@ protocol SettingWorkerProtocol {

final class SettingWorker: SettingWorkerProtocol {

// MARK: - Properties

private let provider: ProviderType

init(provider: ProviderType = Provider()) {
self.provider = provider
}
// MARK: - Methods

func versionNumber() -> String? {
System.versionNumber()
Expand Down
3 changes: 1 addition & 2 deletions iOS/Layover/LayoverTests/Mocks/Workers/MockHomeWorker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
// Copyright © 2023 CodeBomber. All rights reserved.
//

@testable import Layover
import Foundation
import OSLog

@testable import Layover

final class MockHomeWorker: HomeWorkerProtocol {

// MARK: - Properties
Expand Down
18 changes: 18 additions & 0 deletions iOS/Layover/LayoverTests/Mocks/Workers/MockSettingWorker.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// MockSettingWorker.swift
// LayoverTests
//
// Created by 김인환 on 12/13/23.
// Copyright © 2023 CodeBomber. All rights reserved.
//
@testable import Layover
import Foundation

final class MockSettingWorker: SettingWorkerProtocol {

// MARK: - Methods

func versionNumber() -> String? {
"7.7.7"
}
}
38 changes: 19 additions & 19 deletions iOS/Layover/LayoverTests/Scenes/Home/HomeInteractorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,21 @@ final class HomeInteractorTests: XCTestCase {
_ = await sut.fetchPosts(with: request).value

// Assert
XCTAssertTrue(spy.presentPostsCalled, "fetchPost()가 presenter의 presentPosts()를 호출했다.")
XCTAssertEqual(spy.presentPostsReceivedResponse.posts.count, 1, "fetchPost()가 presenter에게 올바른 데이터를 저장했다.")
XCTAssertEqual(spy.presentPostsReceivedResponse.posts[0].tag, Seeds.Posts.post1.tag, "fetchPost()가 presenter에게 올바른 데이터를 저장했다.")
XCTAssertEqual(spy.presentPostsReceivedResponse.posts[0].thumbnailImageData, Seeds.sampleImageData, "fetchPost()가 presenter에게 올바른 데이터를 저장했다.")
XCTAssertEqual(spy.presentPostsReceivedResponse.posts[0].board.identifier, Seeds.Posts.post1.board.identifier, "fetchPost()가 presenter에게 올바른 데이터를 저장했다.")
XCTAssertEqual(spy.presentPostsReceivedResponse.posts[0].board.title, Seeds.Posts.post1.board.title, "fetchPost()가 presenter에게 올바른 데이터를 저장했다.")
XCTAssertEqual(spy.presentPostsReceivedResponse.posts[0].board.description, Seeds.Posts.post1.board.description, "fetchPost()가 presenter에게 올바른 데이터를 저장했다.")
XCTAssertEqual(spy.presentPostsReceivedResponse.posts[0].board.latitude, Seeds.Posts.post1.board.latitude, "fetchPost()가 presenter에게 올바른 데이터를 저장했다.")
XCTAssertEqual(spy.presentPostsReceivedResponse.posts[0].board.longitude, Seeds.Posts.post1.board.longitude, "fetchPost()가 presenter에게 올바른 데이터를 저장했다.")
XCTAssertEqual(spy.presentPostsReceivedResponse.posts[0].board.thumbnailImageURL, Seeds.Posts.post1.board.thumbnailImageURL, "fetchPost()가 presenter에게 올바른 데이터를 저장했다.")
XCTAssertEqual(spy.presentPostsReceivedResponse.posts[0].board.videoURL, Seeds.Posts.post1.board.videoURL, "fetchPost()가 presenter에게 올바른 데이터를 저장했다.")
XCTAssertEqual(spy.presentPostsReceivedResponse.posts[0].member.username, Seeds.Posts.post1.member.username, "fetchPost()가 presenter에게 올바른 데이터를 저장했다.")
XCTAssertEqual(spy.presentPostsReceivedResponse.posts[0].member.introduce, Seeds.Posts.post1.member.introduce, "fetchPost()가 presenter에게 올바른 데이터를 저장했다.")
XCTAssertEqual(spy.presentPostsReceivedResponse.posts[0].member.profileImageURL, Seeds.Posts.post1.member.profileImageURL, "fetchPost()가 presenter에게 올바른 데이터를 저장했다.")
XCTAssertEqual(spy.presentPostsReceivedResponse.posts[0].member.identifier, Seeds.Posts.post1.member.identifier, "fetchPost()가 presenter에게 올바른 데이터를 저장했다.")
XCTAssertTrue(spy.presentPostsCalled, "fetchPost()가 presenter의 presentPosts()를 호출하지 못했다.")
XCTAssertEqual(spy.presentPostsReceivedResponse.posts.count, 1, "fetchPost()가 presenter에게 올바른 데이터 갯수를 저장하지 못했다.")
XCTAssertEqual(spy.presentPostsReceivedResponse.posts[0].tag, Seeds.Posts.post1.tag, "fetchPost()가 presenter에게 올바른 데이터를 저장하지 못했다.")
XCTAssertEqual(spy.presentPostsReceivedResponse.posts[0].thumbnailImageData, Seeds.sampleImageData, "fetchPost()가 presenter에게 올바른 데이터를 저장하지 못했다.")
XCTAssertEqual(spy.presentPostsReceivedResponse.posts[0].board.identifier, Seeds.Posts.post1.board.identifier, "fetchPost()가 presenter에게 올바른 데이터를 저장하지 못했다.")
XCTAssertEqual(spy.presentPostsReceivedResponse.posts[0].board.title, Seeds.Posts.post1.board.title, "fetchPost()가 presenter에게 올바른 데이터를 저장하지 못했다.")
XCTAssertEqual(spy.presentPostsReceivedResponse.posts[0].board.description, Seeds.Posts.post1.board.description, "fetchPost()가 presenter에게 올바른 데이터를 저장하지 못했다.")
XCTAssertEqual(spy.presentPostsReceivedResponse.posts[0].board.latitude, Seeds.Posts.post1.board.latitude, "fetchPost()가 presenter에게 올바른 데이터를 저장하지 못했다.")
XCTAssertEqual(spy.presentPostsReceivedResponse.posts[0].board.longitude, Seeds.Posts.post1.board.longitude, "fetchPost()가 presenter에게 올바른 데이터를 저장하지 못했다.")
XCTAssertEqual(spy.presentPostsReceivedResponse.posts[0].board.thumbnailImageURL, Seeds.Posts.post1.board.thumbnailImageURL, "fetchPost()가 presenter에게 올바른 데이터를 저장하지 못했다.")
XCTAssertEqual(spy.presentPostsReceivedResponse.posts[0].board.videoURL, Seeds.Posts.post1.board.videoURL, "fetchPost()가 presenter에게 올바른 데이터를 저장하지 못했다.")
XCTAssertEqual(spy.presentPostsReceivedResponse.posts[0].member.username, Seeds.Posts.post1.member.username, "fetchPost()가 presenter에게 올바른 데이터를 저장하지 못했다.")
XCTAssertEqual(spy.presentPostsReceivedResponse.posts[0].member.introduce, Seeds.Posts.post1.member.introduce, "fetchPost()가 presenter에게 올바른 데이터를 저장하지 못했다.")
XCTAssertEqual(spy.presentPostsReceivedResponse.posts[0].member.profileImageURL, Seeds.Posts.post1.member.profileImageURL, "fetchPost()가 presenter에게 올바른 데이터를 저장하지 못했다.")
XCTAssertEqual(spy.presentPostsReceivedResponse.posts[0].member.identifier, Seeds.Posts.post1.member.identifier, "fetchPost()가 presenter에게 올바른 데이터를 저장하지 못했다.")
}

func test_playPosts는_자신의_selectedIndex값을_변경한다() async throws {
Expand All @@ -92,7 +92,7 @@ final class HomeInteractorTests: XCTestCase {
sut.playPosts(with: request)

// Assert
XCTAssertEqual(sut.postPlayStartIndex, 101, "playPosts()가 자신의 selectedIndex를 변경했다.")
XCTAssertEqual(sut.postPlayStartIndex, 101, "playPosts()가 자신의 selectedIndex를 변경하지 못했다.")
}

func test_playPosts는_presenter의_presentPlaybackScene를_호출한다() async throws {
Expand All @@ -105,7 +105,7 @@ final class HomeInteractorTests: XCTestCase {
sut.playPosts(with: request)

// Assert
XCTAssertTrue(spy.presentPlaybackSceneCalled, "playPosts()가 presenter의 presentPlaybackScene()를 호출했다.")
XCTAssertTrue(spy.presentPlaybackSceneCalled, "playPosts()가 presenter의 presentPlaybackScene()를 호출하지 않았다.")
}

// TODO: - videoFileWorker Mock 객체 생성 후 테스트 코드 작성
Expand Down Expand Up @@ -138,7 +138,7 @@ final class HomeInteractorTests: XCTestCase {
sut.showTagPlayList(with: request)

// Assert
XCTAssertEqual(sut.selectedTag, "DummyTag", "showTagPlayList()가 자신의 selectedTag를 변경했다.")
XCTAssertEqual(sut.selectedTag, "DummyTag", "showTagPlayList()가 자신의 selectedTag를 변경되지 않았다.")
}

func test_showTagPlayList는_presenter의_presentTagPlayList를_호출한다() {
Expand All @@ -151,6 +151,6 @@ final class HomeInteractorTests: XCTestCase {
sut.showTagPlayList(with: request)

// Assert
XCTAssertTrue(spy.presentTagPlayListCalled, "showTagPlayList()가 presenter의 presentTagPlayList()를 호출했다.")
XCTAssertTrue(spy.presentTagPlayListCalled, "showTagPlayList()가 presenter의 presentTagPlayList()를 호출되지 않았다.")
}
}
24 changes: 12 additions & 12 deletions iOS/Layover/LayoverTests/Scenes/Home/HomePresenterTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ final class HomePresenterTests: XCTestCase {
sut.presentPosts(with: response)

// assert
XCTAssertTrue(spy.displayPostsCalled, "presentPosts는 displayPosts를 실행했다.")
XCTAssertEqual(spy.displayPostsReceivedViewModel.displayedPosts.count, 1, "presentPosts는 올바른 갯수의 데이터를 전달했다.")
XCTAssertEqual(spy.displayPostsReceivedViewModel.displayedPosts[0].tags, Seeds.Posts.post1.tag)
XCTAssertEqual(spy.displayPostsReceivedViewModel.displayedPosts[0].title, Seeds.Posts.post1.board.title)
XCTAssertEqual(spy.displayPostsReceivedViewModel.displayedPosts[0].thumbnailImageURL, Seeds.Posts.post1.board.thumbnailImageURL)
XCTAssertEqual(spy.displayPostsReceivedViewModel.displayedPosts[0].videoURL, Seeds.Posts.post1.board.videoURL, "presentPosts는 올바른 데이터를 전달했다.")
XCTAssertTrue(spy.displayPostsCalled, "presentPosts는 displayPosts를 실행하지 못했다.")
XCTAssertEqual(spy.displayPostsReceivedViewModel.displayedPosts.count, 1, "presentPosts는 올바른 갯수의 데이터를 전달하지 못했다.")
XCTAssertEqual(spy.displayPostsReceivedViewModel.displayedPosts[0].tags, Seeds.Posts.post1.tag, "presentPosts는 올바른 데이터를 전달하지 못했다.")
XCTAssertEqual(spy.displayPostsReceivedViewModel.displayedPosts[0].title, Seeds.Posts.post1.board.title, "presentPosts는 올바른 데이터를 전달하지 못했다.")
XCTAssertEqual(spy.displayPostsReceivedViewModel.displayedPosts[0].thumbnailImageURL, Seeds.Posts.post1.board.thumbnailImageURL, "presentPosts는 올바른 데이터를 전달하지 못했다.")
XCTAssertEqual(spy.displayPostsReceivedViewModel.displayedPosts[0].videoURL, Seeds.Posts.post1.board.videoURL, "presentPosts는 올바른 데이터를 전달하지 못했다.")
}

func test_presentPosts는_데이터의_썸네일_이미지_URL이_nil인_경우_뷰에게_해당_데이터를_전달하지_않는다() {
Expand All @@ -90,8 +90,8 @@ final class HomePresenterTests: XCTestCase {
sut.presentPosts(with: response)

// assert
XCTAssertTrue(spy.displayPostsCalled, "presentPosts는 displayPosts를 실행했다.")
XCTAssertEqual(spy.displayPostsReceivedViewModel.displayedPosts.count, 0, "썸네일 이미지 URL이 nil인 데이터는 뷰에게 전달하지 않는다.")
XCTAssertTrue(spy.displayPostsCalled, "presentPosts는 displayPosts를 실행하지 못했다.")
XCTAssertEqual(spy.displayPostsReceivedViewModel.displayedPosts.count, 0, "썸네일 이미지 URL이 nil인 데이터가 뷰에게 전달되었다.")
}

func test_presentPosts는_데이터의_비디오_URL이_nil인_경우_뷰에게_해당_데이터를_전달하지_않는다() {
Expand All @@ -104,8 +104,8 @@ final class HomePresenterTests: XCTestCase {
sut.presentPosts(with: response)

// assert
XCTAssertTrue(spy.displayPostsCalled, "presentPosts는 displayPosts를 실행했다.")
XCTAssertEqual(spy.displayPostsReceivedViewModel.displayedPosts.count, 0, "비디오 URL이 nil인 데이터는 뷰에게 전달하지 않는다.")
XCTAssertTrue(spy.displayPostsCalled, "presentPosts는 displayPosts를 실행하지 못했다.")
XCTAssertEqual(spy.displayPostsReceivedViewModel.displayedPosts.count, 0, "비디오 URL이 nil인 데이터가 뷰에게 전달되었다.")
}

func test_presentPlaybackScene은_뷰의_routeToPlayback을_실행한다() {
Expand All @@ -117,7 +117,7 @@ final class HomePresenterTests: XCTestCase {
sut.presentPlaybackScene(with: Models.PlayPosts.Response())

// assert
XCTAssertTrue(spy.routeToPlaybackCalled, "presentPlaybackScene은 routeToPlayback을 실행했다.")
XCTAssertTrue(spy.routeToPlaybackCalled, "presentPlaybackScene은 routeToPlayback을 실행하지 못했다.")
}

func test_presentTagPlayList는_뷰의_routeToTagPlayList를_실행한다() {
Expand All @@ -129,7 +129,7 @@ final class HomePresenterTests: XCTestCase {
sut.presentTagPlayList(with: Models.ShowTagPlayList.Response())

// assert
XCTAssertTrue(spy.routeToTagPlayListCalled, "presentTagPlayListScene은 routeToTagPlayList를 실행했다.")
XCTAssertTrue(spy.routeToTagPlayListCalled, "presentTagPlayListScene은 routeToTagPlayList를 실행하지 못했다.")
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ final class HomeViewControllerTests: XCTestCase {
sut.routeToPlayback()

// assert
XCTAssertTrue(spy.routeToPlaybackCalled, "routeToPlayback 호출 시 router의 routeToPlayback이 호출되었다.")
XCTAssertTrue(spy.routeToPlaybackCalled, "routeToPlayback 호출 시 router의 routeToPlayback이 호출되지 않았다.")
}

func test_routeToTagPlayList_호출시_router의_routeToTagPlay를_호출한다() {
Expand All @@ -117,6 +117,6 @@ final class HomeViewControllerTests: XCTestCase {
sut.routeToTagPlayList()

// assert
XCTAssertTrue(spy.routeToTagPlayCalled, "routeToTagPlayList 호출 시 router의 routeToTagPlay가 호출되었다.")
XCTAssertTrue(spy.routeToTagPlayCalled, "routeToTagPlayList 호출 시 router의 routeToTagPlay가 호출되지 않았다.")
}
}
Loading