-
Notifications
You must be signed in to change notification settings - Fork 168
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
CClipboard の単体テストをさらに追加する #1843
Merged
kengoide
merged 4 commits into
sakura-editor:master
from
kengoide:feature/more-tests-for-cclipboard-redux
May 8, 2022
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
カバレッジが想定より低いのは、API呼出をモック化するために追加したこれらのメソッドがテストで実行されないためと考えられます。(テストで動くのはモックコードだから、ここは動かない)
テストではクリップボードのAPIを呼ばないようにして、クリップボードが勝手に書き換わる事態を回避しよう!で始めた対応なので、APIを呼ばないこと自体は気にしなくて良い認識です。
「CClipboardクラスのテストカバレッジ」を考えたときに、「テストで実行されないメソッドがある」の状態なので、何か対策したほうがいいような気はします。(というか、ちょっと自分でやりたいです:smiley:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
対策としては別のクラスに実装してコンストラクタで注入するといったところでしょうか? そういう手法の方がモックの作り方としては一般的らしく、設計を再考してもいいかもしれませんね。何かこの件で案があればぜひお知らせください。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
テスト導入のときに書いた気がするんですけど、
APIラッパー部分を
CClipbordApi
とかの別クラスに分割してあげれば、CClipboard
クラスのカバレッジは限りなく100%にできます。実装コードの検証をしたいのは独自に組んだロジックだけなので、とりあえずソコが目標になるはず。
コンストラクタで注入(=依存関係の逆転)は、やれたらカッコイイですね。
サクラエディタのWinMainはDIを実装できるほど簡潔でないように思います。
問題点「WinMainが簡潔でない」の対策は大変なので、当面は放置ですかね...。