C#コーディング問題(xUnit版) metatest置き換え#50
Draft
Syogo-Suganoya wants to merge 3 commits intocontents/coding-csharp-xunitfrom
Draft
C#コーディング問題(xUnit版) metatest置き換え#50Syogo-Suganoya wants to merge 3 commits intocontents/coding-csharp-xunitfrom
Syogo-Suganoya wants to merge 3 commits intocontents/coding-csharp-xunitfrom
Conversation
Syogo-Suganoya
commented
Mar 31, 2023
Contributor
Author
Syogo-Suganoya
left a comment
There was a problem hiding this comment.
XunitContextとNUnitを試してみましたが、動作しませんでした。
|
|
||
| Assert.Equal(expected, result); | ||
|
|
||
| if (XunitContext.Context.TestStatus == TestStatus.Failed) |
Contributor
Author
There was a problem hiding this comment.
XunitContext
The type or namespace name 'XunitContext' could not be foundが出力されます。
csprojに<PackageReference Include="XunitContext" Version="3.2.5" />は追加済み。
|
|
||
| if (TestContext.CurrentContext.Result.Outcome.Status == NUnit.Framework.Interfaces.TestStatus.Failed) | ||
| { | ||
| TestContext.WriteLine("Test failed."); |
Contributor
Author
There was a problem hiding this comment.
NUnit
標準出力がされないです。
Console.WriteLine("Test failed."); でも同様です。
Syogo-Suganoya
commented
Apr 12, 2023
Contributor
Author
Syogo-Suganoya
left a comment
There was a problem hiding this comment.
簡単にまとめるとこのような状況です。
- xUnit
出力ができるが、テスト結果が取得できない - NUnit
出力ができない
|
|
||
| Assert.AreEqual(expected, result); | ||
|
|
||
| output.WriteLine("This is output from TestMethod"); |
Contributor
Author
There was a problem hiding this comment.
以前 xunit でテストコード書いたときは TestOutputHelper を使っていました。ご参考になるかわからんですが。
NUnitにTestOutputHelperを入れてみましたが、出力されませんでした。
> sh scripts/test_run.sh
Determining projects to restore...
Restored /root/src/src/main/main.csproj (in 2.14 sec).
Restored /root/src/src/test/test.csproj (in 2.14 sec).ここまでで出力が終わります。
scripts/test_run.sh の内容
#!/usr/bin/bash
cd /root/src/src/test
dotnet test;
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
概要
xUnitを使用したチャレンジを作成しています。
このチャレンジは、顧客企業にチュートリアル用に展開するものです。既存で使用しているmetatestはやや複雑なので、シンプルにxUnit(NUnit)の機能のみで採点されるようにしようとしています。
要件
[hoge] fugaの形式で出力できるok x ...not ok x ...例
関連
#48