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

Update unit tests for the logging system. #4

Merged
merged 24 commits into from
Aug 20, 2021
Merged

Update unit tests for the logging system. #4

merged 24 commits into from
Aug 20, 2021

Conversation

Takym
Copy link
Owner

@Takym Takym commented Jun 11, 2021

cocoa-mhlw#67 の単体テストのエラーを修正する為に実験しています。
この PR は差分を確認する為に使っています。

@Takym Takym self-assigned this Jun 11, 2021
Merge branch 'cocoa-mhlw:develop' into logging
@Takym Takym changed the title Logging Test Logging Unit Test Jun 11, 2021
@Takym
Copy link
Owner Author

Takym commented Jun 11, 2021

cocoa-mhlw#67 (comment) から

テスト失敗について

ログを見る限り下記の処理で失敗している様です。

using (var sr = new StreamReader("~/.cocoa/logs/cocoa_log_20201101.csv"))

Mock.Get(mockILogPathService).Verify(s => s.LogsDirPath, Times.Exactly(2));

Mock.Get(mockILogPathService).Verify(s => s.LogsDirPath, Times.Once());

Mock.Get(mockILogPathService).Verify(s => s.LogsDirPath, Times.Once());

@Takym
Copy link
Owner Author

Takym commented Jun 11, 2021

cocoa-mhlw#67 (comment) から

テスト失敗について

自分の環境の Visual Studio で実験してみた所、「System.IO.IOException : The process cannot access the file '<ログファイル名>' because it is being used by another process.」というエラーが出て失敗しました。しかし、LogWriter.LogFile ではファイルの共有は読み取りと書き込みの両方を許可している筈です。

追記1

DeleteLogsDirIfExists を無効化して試しています。

追記2

LoggerServiceTests では文字列でファイル名を指定しています。そして、文字列でファイル名を渡した場合、StreamReader のコンストラクタ内部では FileShare.Read でストリームを作成している様です。これが原因の可能性もありそうです。

@Takym
Copy link
Owner Author

Takym commented Jun 11, 2021

1fd2885 によりファイルの共有エラーは改善したが、別のエラーが発生した。

追記

原因は DeleteLogsDirIfExists を無効化しているためだった。

@Takym
Copy link
Owner Author

Takym commented Jun 11, 2021

9cef515 により DeleteLogsDirIfExists を再び有効化した。殆どのエラーは消えたが、まだ動かないテストケースもある。

  • Info_Success_Async
  • StartMethod_Success
  • StartMethod_Success_LogsDir_Exists_LogFile_Exists
  • StartMethod_Success_LogsDir_Exists_LogFile_Not_Exists
  • StartMethod_Success_LogsDir_Not_Exists
  • OpenWebViewCommandTests

@Takym
Copy link
Owner Author

Takym commented Jun 23, 2021

テストケースを少し修正したら更にエラーが改善された。
CSV は正規表現で解析していたが、読み難かったので解析処理を CocoaLogViewer から拝借してきた。


HomePage の OpenWebViewCommandTests は恐らく PC の言語(日本語)とテストケースの言語(英語)が一致しない為にエラーが発生している。

@Takym
Copy link
Owner Author

Takym commented Jun 23, 2021

残りのエラーはマルチタスクが原因であると思われる。

@Takym
Copy link
Owner Author

Takym commented Jun 23, 2021

StartMethod_Success は null 値が原因でエラーが発生していた(修正済み)。

@Takym
Copy link
Owner Author

Takym commented Jun 23, 2021

排他制御に関する問題の原因は不明。

@Takym Takym closed this Jul 1, 2021
@Takym Takym reopened this Jul 1, 2021
@Takym Takym closed this Jul 1, 2021
@Takym Takym reopened this Jul 1, 2021
@Takym Takym closed this Jul 1, 2021
@Takym Takym reopened this Jul 1, 2021
@Takym
Copy link
Owner Author

Takym commented Jul 6, 2021

排他制御に関する問題は修正した。

残りのエラーは下記の4つ。

@Takym Takym closed this Aug 20, 2021
@Takym Takym reopened this Aug 20, 2021
@Takym Takym changed the title Logging Unit Test Update unit tests for the logging system. Aug 20, 2021
@Takym
Copy link
Owner Author

Takym commented Aug 20, 2021

下記三つの失敗の原因は LogFilePath の呼び出し回数によるものだった。

  • StartMethod_Success_LogsDir_Exists_LogFile_Exists
  • StartMethod_Success_LogsDir_Exists_LogFile_Not_Exists
  • StartMethod_Success_LogsDir_Not_Exists

@Takym Takym merged commit ac1f49f into logging Aug 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant