NUnitの3、VS2015
は、私が使用してTestCase
属性を通じて私の方法の例外タイプをテストしたいのですが、VS2015での私のテストをNUnit3TestAdapter
見ていない(私のクラスはpublic
です):私のメソッドの例外のセットは、1回のテストだけでどのようにテストできますか?
[TestCase(null, typeof(ArgumentNullException))]
[TestCase("", typeof(ArgumentException))]
[TestCase(" ", typeof(ArgumentException))]
[TestCase(" \t \t ", typeof(ArgumentException))]
[TestCase("< !!!>", typeof(FileNotFoundException))]
public void InvalidFilePath_ThrowsException<T>(string name,
T exception_type) where T : Exception {
Dictionary<string, string> dict = new Dictionary<string, string>();
Assert.Throws<T>(() => ModelFactory.Current.CreateDocument(name,
dict));
}
さらに:でこの場合NUnit3TestAdapter
が私のすべてのテストを見ていない...しかし、私はこのテストをコメントする場合は、NUnit3TestAdapter
は、他のテストを見ている:
// [TestCase(null, typeof(ArgumentNullException))]
// [TestCase("", typeof(ArgumentException))]
// [TestCase(" ", typeof(ArgumentException))]
// [TestCase(" \t \t ", typeof(ArgumentException))]
// [TestCase("<!!!>", typeof(FileNotFoundException))]
// public void InvalidFilePath_ThrowsException<T>(string name,
// T exception_type) where T : Exception {
// Dictionary<string, string> dict = new Dictionary<string, string>();
// Assert.Throws<T>(() => ModelFactory.Current.CreateDocument(name,
// dict));
//}
[Test]
public void InvalidFilePath_ThrowsException_01() {
Dictionary<string, string> dict = new Dictionary<string, string>();
Assert.Throws<ArgumentNullException>(() => ModelFactory.Current
.CreateDocument(null, dict));
}
[Test]
public void InvalidFilePath_ThrowsException_02() {
Dictionary<string, string> dict = new Dictionary<string, string>();
Assert.Throws<ArgumentException>(() => ModelFactory.Current
.CreateDocument("", dict));
}
[Test]
public void InvalidFilePath_ThrowsException_03() {
Dictionary<string, string> dict = new Dictionary<string, string>();
Assert.Throws<ArgumentException>(() => ModelFactory.Current
.CreateDocument(" ", dict));
}
[Test]
public void InvalidFilePath_ThrowsException_04() {
Dictionary<string, string> dict = new Dictionary<string, string>();
Assert.Throws<ArgumentException>(() => ModelFactory.Current
.CreateDocument(" \t \t ", dict));
}
[Test]
public void InvalidFilePath_ThrowsException_05() {
Dictionary<string, string> dict = new Dictionary<string, string>();
Assert.Throws<FileNotFoundException>(() => ModelFactory.Current
.CreateDocument("<!!!>", dict));
}
は、どのように私はそれを解決することができますか?私は5つの別々のテストを作成したくないです...
ルック:http://stackoverflow.com/questions/801153/parametric-test-with-generic-methods – vyrp
どのようにその情報は私のケースで私を助けることができますか? –
回答を投稿しました – vyrp