diff --git a/src/Adapter/MSTest.TestAdapter/Resources/Resource.Designer.cs b/src/Adapter/MSTest.TestAdapter/Resources/Resource.Designer.cs
index 04ed583d34..20f0e0e90f 100644
--- a/src/Adapter/MSTest.TestAdapter/Resources/Resource.Designer.cs
+++ b/src/Adapter/MSTest.TestAdapter/Resources/Resource.Designer.cs
@@ -605,7 +605,7 @@ internal static string UTA_ErrorInValidTestContextSignature {
}
///
- /// Looks up a localized string similar to UTA054: {0}.{1} has invalid Timeout attribute. The timeout must be a valid integer value and cannot be less than 0..
+ /// Looks up a localized string similar to UTA054: {0}.{1} has invalid Timeout attribute. The timeout must be an integer value greater than 0..
///
internal static string UTA_ErrorInvalidTimeout {
get {
diff --git a/src/Adapter/MSTest.TestAdapter/Resources/Resource.resx b/src/Adapter/MSTest.TestAdapter/Resources/Resource.resx
index 124c9530a4..ea788a39f5 100644
--- a/src/Adapter/MSTest.TestAdapter/Resources/Resource.resx
+++ b/src/Adapter/MSTest.TestAdapter/Resources/Resource.resx
@@ -212,7 +212,7 @@ Error: {1}
Method {0}.{1} has wrong signature. The method must be static, public, does not return a value and should take a single parameter of type TestContext. Additionally, if you are using async-await in method then return-type must be 'Task' or 'ValueTask'.
- UTA054: {0}.{1} has invalid Timeout attribute. The timeout must be a valid integer value and cannot be less than 0.
+ UTA054: {0}.{1} has invalid Timeout attribute. The timeout must be an integer value greater than 0.UTA023: {0}: Cannot define predefined property {2} on method {1}.
diff --git a/src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.cs.xlf b/src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.cs.xlf
index 19d5657bc2..2ba3918178 100644
--- a/src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.cs.xlf
+++ b/src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.cs.xlf
@@ -244,9 +244,9 @@ Chyba: {1}
-
- UTA054: {0}.{1} má neplatný atribut Timeout. Timeout musí být platné celé číslo a nesmí být menší než 0.
-
+
+ UTA054: {0}.{1} má neplatný atribut Timeout. Timeout musí být platné celé číslo a nesmí být menší než 0.
+
diff --git a/src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.de.xlf b/src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.de.xlf
index 813b6b8438..5ee9375717 100644
--- a/src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.de.xlf
+++ b/src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.de.xlf
@@ -244,9 +244,9 @@ Fehler: {1}
-
- UTA054: "{0}.{1}" weist ein ungültiges Attribut "Timeout" auf. Das Timeout muss ein gültiger ganzzahliger Wert sein und darf nicht kleiner als 0 sein.
-
+
+ UTA054: "{0}.{1}" weist ein ungültiges Attribut "Timeout" auf. Das Timeout muss ein gültiger ganzzahliger Wert sein und darf nicht kleiner als 0 sein.
+
diff --git a/src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.es.xlf b/src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.es.xlf
index aaf2267cd9..5bdac3e501 100644
--- a/src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.es.xlf
+++ b/src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.es.xlf
@@ -244,9 +244,9 @@ Error: {1}
-
- UTA054: atributo tiempo espera {0}.{1} no válido. Valor tiempo de espera debe ser entero válido y no menor que 0.
-
+
+ UTA054: atributo tiempo espera {0}.{1} no válido. Valor tiempo de espera debe ser entero válido y no menor que 0.
+
diff --git a/src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.fr.xlf b/src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.fr.xlf
index 7fcbaff3ad..e69c5c8218 100644
--- a/src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.fr.xlf
+++ b/src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.fr.xlf
@@ -244,9 +244,9 @@ Erreur : {1}
-
- UTA054 : {0}.{1} possède un attribut Timeout non valide. Timeout doit être une valeur entière valide, qui ne doit pas être inférieure à 0.
-
+
+ UTA054 : {0}.{1} possède un attribut Timeout non valide. Timeout doit être une valeur entière valide, qui ne doit pas être inférieure à 0.
+
diff --git a/src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.it.xlf b/src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.it.xlf
index dc44fdc1a9..d0111cd810 100644
--- a/src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.it.xlf
+++ b/src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.it.xlf
@@ -244,9 +244,9 @@ Errore: {1}
-
- UTA054: l'attributo Timeout di {0}.{1} non è valido. Il timeout deve essere un valore intero valido non minore di 0.
-
+
+ UTA054: l'attributo Timeout di {0}.{1} non è valido. Il timeout deve essere un valore intero valido non minore di 0.
+
diff --git a/src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.ja.xlf b/src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.ja.xlf
index 2e8d0ade3f..f798d0a9b9 100644
--- a/src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.ja.xlf
+++ b/src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.ja.xlf
@@ -245,9 +245,9 @@ Error: {1}
-
- UTA054: {0}.{1} は無効な Timeout 属性を含んでいます。タイムアウトは有効な整数値でなければなりません。0 よりも小さい値にすることはできません。
-
+
+ UTA054: {0}.{1} は無効な Timeout 属性を含んでいます。タイムアウトは有効な整数値でなければなりません。0 よりも小さい値にすることはできません。
+
diff --git a/src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.ko.xlf b/src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.ko.xlf
index 0e79807fb8..887a1c1016 100644
--- a/src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.ko.xlf
+++ b/src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.ko.xlf
@@ -244,9 +244,9 @@ Error: {1}
-
- UTA054: {0}.{1}에 잘못된 Timeout 특성이 있습니다. Timeout은 유효한 정수 값이어야 하며 0보다 작을 수 없습니다.
-
+
+ UTA054: {0}.{1}에 잘못된 Timeout 특성이 있습니다. Timeout은 유효한 정수 값이어야 하며 0보다 작을 수 없습니다.
+
diff --git a/src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.pl.xlf b/src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.pl.xlf
index 2f31550dc4..761f34884e 100644
--- a/src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.pl.xlf
+++ b/src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.pl.xlf
@@ -244,9 +244,9 @@ Błąd: {1}
-
- UTA054: {0}.{1} ma nieprawidłowy atrybut Timeout. Limit czasu musi być prawidłową liczbą całkowitą i nie może być mniejszy niż 0.
-
+
+ UTA054: {0}.{1} ma nieprawidłowy atrybut Timeout. Limit czasu musi być prawidłową liczbą całkowitą i nie może być mniejszy niż 0.
+
diff --git a/src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.pt-BR.xlf b/src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.pt-BR.xlf
index 5068806ecf..4c34bc1a4e 100644
--- a/src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.pt-BR.xlf
+++ b/src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.pt-BR.xlf
@@ -244,9 +244,9 @@ Erro: {1}
-
- UTA054: {0}.{1} tem atributo Timeout inválido. O tempo limite deve ser um valor inteiro válido e não pode ser menor que 0.
-
+
+ UTA054: {0}.{1} tem atributo Timeout inválido. O tempo limite deve ser um valor inteiro válido e não pode ser menor que 0.
+
diff --git a/src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.ru.xlf b/src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.ru.xlf
index fffea6baae..338336bcd5 100644
--- a/src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.ru.xlf
+++ b/src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.ru.xlf
@@ -244,9 +244,9 @@ Error: {1}
-
- UTA054: {0}.{1} имеет недопустимый атрибут Timeout. Время ожидания должно быть допустимым целым числом и не может быть меньше 0.
-
+
+ UTA054: {0}.{1} имеет недопустимый атрибут Timeout. Время ожидания должно быть допустимым целым числом и не может быть меньше 0.
+
diff --git a/src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.tr.xlf b/src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.tr.xlf
index 9ad699359b..ceb49b4abb 100644
--- a/src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.tr.xlf
+++ b/src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.tr.xlf
@@ -244,9 +244,9 @@ Hata: {1}
-
- UTA054: {0}.{1} geçersiz Timeout özniteliğine sahip. Zaman aşımı geçerli bir tamsayı değer olmalıdır ve 0'dan küçük olamaz.
-
+
+ UTA054: {0}.{1} geçersiz Timeout özniteliğine sahip. Zaman aşımı geçerli bir tamsayı değer olmalıdır ve 0'dan küçük olamaz.
+
diff --git a/src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.zh-Hans.xlf b/src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.zh-Hans.xlf
index 90b86aa37c..811ac3ce24 100644
--- a/src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.zh-Hans.xlf
+++ b/src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.zh-Hans.xlf
@@ -244,9 +244,9 @@ Error: {1}
-
- UTA054: {0}.{1} 具有无效的 Timeout 特性。超时值必须是有效的整数值而且不能小于 0。
-
+
+ UTA054: {0}.{1} 具有无效的 Timeout 特性。超时值必须是有效的整数值而且不能小于 0。
+
diff --git a/src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.zh-Hant.xlf b/src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.zh-Hant.xlf
index 8a2fe5e8a7..74259cbc3b 100644
--- a/src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.zh-Hant.xlf
+++ b/src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.zh-Hant.xlf
@@ -244,9 +244,9 @@ Error: {1}
-
- UTA054: {0}.{1} 中具有無效的 Timeout 屬性。逾時值必須是有效的整數值,而且不可小於 0。
-
+
+ UTA054: {0}.{1} 中具有無效的 Timeout 屬性。逾時值必須是有效的整數值,而且不可小於 0。
+
diff --git a/test/UnitTests/MSTestAdapter.UnitTests/Execution/TypeCacheTests.cs b/test/UnitTests/MSTestAdapter.UnitTests/Execution/TypeCacheTests.cs
index 9737d3f08b..bacb7ee0bd 100644
--- a/test/UnitTests/MSTestAdapter.UnitTests/Execution/TypeCacheTests.cs
+++ b/test/UnitTests/MSTestAdapter.UnitTests/Execution/TypeCacheTests.cs
@@ -917,10 +917,10 @@ public void GetTestMethodInfoShouldReturnTestMethodInfoWithTimeout()
Verify(testMethodInfo.TestMethodOptions.Executor is not null);
}
- public void GetTestMethodInfoShouldThrowWhenTimeoutIsIncorrect()
+ public void GetTestMethodInfoShouldThrowWhenTimeoutIsNegative()
{
Type type = typeof(DummyTestClassWithTestMethods);
- MethodInfo methodInfo = type.GetMethod("TestMethodWithIncorrectTimeout");
+ MethodInfo methodInfo = type.GetMethod("TestMethodWithNegativeTimeout");
var testMethod = new TestMethod(methodInfo.Name, type.FullName, "A", isAsync: false);
_mockReflectHelper.Setup(rh => rh.IsNonDerivedAttributeDefined(methodInfo, false))
@@ -939,7 +939,36 @@ void A() => _typeCache.GetTestMethodInfo(
string expectedMessage =
string.Format(
CultureInfo.InvariantCulture,
- "UTA054: {0}.{1} has invalid Timeout attribute. The timeout must be a valid integer value and cannot be less than 0.",
+ "UTA054: {0}.{1} has invalid Timeout attribute. The timeout must be an integer value greater than 0.",
+ testMethod.FullClassName,
+ testMethod.Name);
+
+ Verify(expectedMessage == exception.Message);
+ }
+
+ public void GetTestMethodInfoShouldThrowWhenTimeoutIsZero()
+ {
+ Type type = typeof(DummyTestClassWithTestMethods);
+ MethodInfo methodInfo = type.GetMethod("TestMethodWithTimeoutOfZero");
+ var testMethod = new TestMethod(methodInfo.Name, type.FullName, "A", isAsync: false);
+
+ _mockReflectHelper.Setup(rh => rh.IsNonDerivedAttributeDefined(methodInfo, false))
+ .Returns(true);
+
+ void A() => _typeCache.GetTestMethodInfo(
+ testMethod,
+ new TestContextImplementation(testMethod, new ThreadSafeStringWriter(null, "test"), new Dictionary()),
+ false);
+
+ Exception exception = VerifyThrows(A);
+
+ Verify(exception is not null);
+ Verify(exception is TypeInspectionException);
+
+ string expectedMessage =
+ string.Format(
+ CultureInfo.InvariantCulture,
+ "UTA054: {0}.{1} has invalid Timeout attribute. The timeout must be an integer value greater than 0.",
testMethod.FullClassName,
testMethod.Name);
@@ -1413,7 +1442,13 @@ public void TestMethodWithTimeout()
[UTF.TestMethod]
[UTF.Timeout(-10)]
- public void TestMethodWithIncorrectTimeout()
+ public void TestMethodWithNegativeTimeout()
+ {
+ }
+
+ [UTF.TestMethod]
+ [UTF.Timeout(0)]
+ public void TestMethodWithTimeoutOfZero()
{
}