問題タブ [expected-exception]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票する
1 に答える
985 参照

c# - ExpectedExceptionを伴うMbunitファクトリ属性

Factory属性を使用するときに、特定の入力に対して特定の例外が発生することを期待していると書く方法はありますか?Row属性を使用してそれを行う方法は知っていますが、動的に生成されるテスト入力に必要です。

提供された文字列の逆関数を返す関数については、以下のテスト例を参照してください。

0 投票する
1 に答える
341 参照

c# - 失敗メッセージを ExpectedException 属性で提供する方法はありますか?

アサーションが失敗したときにメッセージを表示したいのですが、方法がわかりません。

このテストではどうすればよいですか?

0 投票する
1 に答える
1844 参照

c# - NUnit、ExpectedException、yield return の奇妙な動作

null がパラメーターとして渡されたときに例外がスローされることをテストしたいテストで奇妙な動作があります。テストを実行すると、NUnit から取得されます。

私のテスト:

私の実装:

この動作には論理的な説明がありますか?実装を別の方法で行う必要がありますか?

0 投票する
1 に答える
123 参照

tdd - テストするコードが例外をキャッチして再スローしない場合でも、MSTest [TestMethod] は失敗しますか?

私は MSTest を使用しており、[TestMethod] にはコードが例外をスローするオブジェクトがあり、それをキャッチします。特定の状況では再スローしますが、再スローしない場合もありますが、何度か再スローしなくても、テストは常に失敗し、例外がスローされたことを示します。条件付きで例外を無視するにはどうすればよいですか? 条件付きなので、例外を再スローするかどうかにかかわらず、[ExpectedException] は使用できません。

0 投票する
1 に答える
325 参照

asp.net - ExpectedExceptionを使用してDatabaseConnectionエラーのASP.NET C#でテストケースを作成するにはどうすればよいですか?

データベース接続エラーのテスト ケースを作成したいと考えています。

これを行う方法はありますか?

0 投票する
1 に答える
664 参照

java - How can I test several exceptions within one test using an ExpectedException Rule?

Got a question regarding the usage of junit's ExpectedException rule:

As suggested here: junit ExpectedException Rule starting from junit 4.7 one can test exceptions like this (which is much better then the @Test(expected=Exception.class)):

Now I needed to test several exceptions in one test method and got a green bar after running the following test and thus thought every test passed.

However after a while I realized that the testmethod is quit after the first check passes. This is ambiguous to say the least. In junit 3 this was easily possible... So here is my question:

How can I test several exceptions within one test using an ExpectedException Rule?