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

Reword unhandled TestMethodAttribute.Execute exception message #4641

Merged
merged 3 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/Adapter/MSTest.TestAdapter/Execution/TestMethodRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -435,10 +435,13 @@ private TestResult[] ExecuteTest(TestMethodInfo testMethodInfo)
[
new TestResult()
{
// TODO: We need to change the exception type to more specific one.
#pragma warning disable CA2201 // Do not raise reserved exception types
TestFailureException = new Exception(string.Format(CultureInfo.CurrentCulture, Resource.UTA_ExecuteThrewException, ex.Message, ex.StackTrace), ex),
#pragma warning restore CA2201 // Do not raise reserved exception types
TestFailureException = new InvalidOperationException(
string.Format(
CultureInfo.CurrentCulture,
Resource.UTA_ExecuteThrewException,
_testMethodInfo.TestMethodOptions.Executor.GetType().FullName,
ex.ToString()),
ex),
},
];
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/Adapter/MSTest.TestAdapter/Resources/Resource.resx
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ Error: {1}</value>
<value>Class Initialization method {0}.{1} threw exception. {2}: {3}.</value>
</data>
<data name="UTA_ExecuteThrewException" xml:space="preserve">
<value>Exception thrown while executing test. If using extension of TestMethodAttribute then please contact vendor. Error message: {0}, Stack trace: {1}</value>
<value>An unhandled exception was thrown by the 'Execute' method. Please report this error to the author of the attribute '{0}'.
{1}</value>
</data>
<data name="UTA_NoTestResult" xml:space="preserve">
<value>Error in executing test. No result returned by extension. If using extension of TestMethodAttribute then please contact vendor.</value>
Expand Down
7 changes: 4 additions & 3 deletions src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.cs.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,10 @@ Chyba: {1}</target>
<note></note>
</trans-unit>
<trans-unit id="UTA_ExecuteThrewException">
<source>Exception thrown while executing test. If using extension of TestMethodAttribute then please contact vendor. Error message: {0}, Stack trace: {1}</source>
<target state="translated">Při provádění testu se vyvolala výjimka. Pokud používáte rozšíření TestMethodAttribute, obraťte se prosím na dodavatele. Chybová zpráva: {0}, trasování zásobníku: {1}</target>
<note></note>
<source>An unhandled exception was thrown by the 'Execute' method. Please report this error to the author of the attribute '{0}'.
{1}</source>
<target state="needs-review-translation">Při provádění testu se vyvolala výjimka. Pokud používáte rozšíření TestMethodAttribute, obraťte se prosím na dodavatele. Chybová zpráva: {0}, trasování zásobníku: {1}</target>
<note />
</trans-unit>
<trans-unit id="UTA_NoTestResult">
<source>Error in executing test. No result returned by extension. If using extension of TestMethodAttribute then please contact vendor.</source>
Expand Down
7 changes: 4 additions & 3 deletions src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.de.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,10 @@ Fehler: {1}</target>
<note></note>
</trans-unit>
<trans-unit id="UTA_ExecuteThrewException">
<source>Exception thrown while executing test. If using extension of TestMethodAttribute then please contact vendor. Error message: {0}, Stack trace: {1}</source>
<target state="translated">Ausnahme beim Ausführen des Tests. Wenn Sie die Erweiterung "TestMethodAttribute" verwenden, wenden Sie sich an den Hersteller. Fehlermeldung: {0}, Stapelüberwachung: {1}</target>
<note></note>
<source>An unhandled exception was thrown by the 'Execute' method. Please report this error to the author of the attribute '{0}'.
{1}</source>
<target state="needs-review-translation">Ausnahme beim Ausführen des Tests. Wenn Sie die Erweiterung "TestMethodAttribute" verwenden, wenden Sie sich an den Hersteller. Fehlermeldung: {0}, Stapelüberwachung: {1}</target>
<note />
</trans-unit>
<trans-unit id="UTA_NoTestResult">
<source>Error in executing test. No result returned by extension. If using extension of TestMethodAttribute then please contact vendor.</source>
Expand Down
7 changes: 4 additions & 3 deletions src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.es.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,10 @@ Error: {1}</target>
<note></note>
</trans-unit>
<trans-unit id="UTA_ExecuteThrewException">
<source>Exception thrown while executing test. If using extension of TestMethodAttribute then please contact vendor. Error message: {0}, Stack trace: {1}</source>
<target state="translated">Se inició una excepción al ejecutar la prueba. Si usa la extensión de TestMethodAttribute, póngase en contacto con el proveedor. Mensaje de error: {0}, seguimiento: {1}</target>
<note></note>
<source>An unhandled exception was thrown by the 'Execute' method. Please report this error to the author of the attribute '{0}'.
{1}</source>
<target state="needs-review-translation">Se inició una excepción al ejecutar la prueba. Si usa la extensión de TestMethodAttribute, póngase en contacto con el proveedor. Mensaje de error: {0}, seguimiento: {1}</target>
<note />
</trans-unit>
<trans-unit id="UTA_NoTestResult">
<source>Error in executing test. No result returned by extension. If using extension of TestMethodAttribute then please contact vendor.</source>
Expand Down
7 changes: 4 additions & 3 deletions src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.fr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,10 @@ Erreur : {1}</target>
<note></note>
</trans-unit>
<trans-unit id="UTA_ExecuteThrewException">
<source>Exception thrown while executing test. If using extension of TestMethodAttribute then please contact vendor. Error message: {0}, Stack trace: {1}</source>
<target state="translated">Exception levée pendant l'exécution du test. Si vous utilisez l'extension de TestMethodAttribute, contactez le fournisseur. Message d'erreur : {0}, Rapport des appels de procédure : {1}</target>
<note></note>
<source>An unhandled exception was thrown by the 'Execute' method. Please report this error to the author of the attribute '{0}'.
{1}</source>
<target state="needs-review-translation">Exception levée pendant l'exécution du test. Si vous utilisez l'extension de TestMethodAttribute, contactez le fournisseur. Message d'erreur : {0}, Rapport des appels de procédure : {1}</target>
<note />
</trans-unit>
<trans-unit id="UTA_NoTestResult">
<source>Error in executing test. No result returned by extension. If using extension of TestMethodAttribute then please contact vendor.</source>
Expand Down
7 changes: 4 additions & 3 deletions src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.it.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,10 @@ Errore: {1}</target>
<note></note>
</trans-unit>
<trans-unit id="UTA_ExecuteThrewException">
<source>Exception thrown while executing test. If using extension of TestMethodAttribute then please contact vendor. Error message: {0}, Stack trace: {1}</source>
<target state="translated">È stata generata un'eccezione durante l'esecuzione del test. Se si usa l'estensione di TestMethodAttribute, contattare il fornitore. Messaggio di errore: {0}, analisi dello stack: {1}</target>
<note></note>
<source>An unhandled exception was thrown by the 'Execute' method. Please report this error to the author of the attribute '{0}'.
{1}</source>
<target state="needs-review-translation">È stata generata un'eccezione durante l'esecuzione del test. Se si usa l'estensione di TestMethodAttribute, contattare il fornitore. Messaggio di errore: {0}, analisi dello stack: {1}</target>
<note />
</trans-unit>
<trans-unit id="UTA_NoTestResult">
<source>Error in executing test. No result returned by extension. If using extension of TestMethodAttribute then please contact vendor.</source>
Expand Down
7 changes: 4 additions & 3 deletions src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.ja.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,10 @@ Error: {1}</source>
<note></note>
</trans-unit>
<trans-unit id="UTA_ExecuteThrewException">
<source>Exception thrown while executing test. If using extension of TestMethodAttribute then please contact vendor. Error message: {0}, Stack trace: {1}</source>
<target state="translated">テストの実行中に例外がスローされました。TestMethodAttribute の拡張クラスを使用している場合は、ベンダーに連絡してください。エラー メッセージ: {0}、スタック トレース: {1}</target>
<note></note>
<source>An unhandled exception was thrown by the 'Execute' method. Please report this error to the author of the attribute '{0}'.
{1}</source>
<target state="needs-review-translation">テストの実行中に例外がスローされました。TestMethodAttribute の拡張クラスを使用している場合は、ベンダーに連絡してください。エラー メッセージ: {0}、スタック トレース: {1}</target>
<note />
</trans-unit>
<trans-unit id="UTA_NoTestResult">
<source>Error in executing test. No result returned by extension. If using extension of TestMethodAttribute then please contact vendor.</source>
Expand Down
7 changes: 4 additions & 3 deletions src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.ko.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,10 @@ Error: {1}</source>
<note></note>
</trans-unit>
<trans-unit id="UTA_ExecuteThrewException">
<source>Exception thrown while executing test. If using extension of TestMethodAttribute then please contact vendor. Error message: {0}, Stack trace: {1}</source>
<target state="translated">테스트를 실행하는 동안 예외가 발생했습니다. TestMethodAttribute 확장을 사용하는 경우 공급업체에 문의하세요. 오류 메시지: {0}. 스택 추적: {1}</target>
<note></note>
<source>An unhandled exception was thrown by the 'Execute' method. Please report this error to the author of the attribute '{0}'.
{1}</source>
<target state="needs-review-translation">테스트를 실행하는 동안 예외가 발생했습니다. TestMethodAttribute 확장을 사용하는 경우 공급업체에 문의하세요. 오류 메시지: {0}. 스택 추적: {1}</target>
<note />
</trans-unit>
<trans-unit id="UTA_NoTestResult">
<source>Error in executing test. No result returned by extension. If using extension of TestMethodAttribute then please contact vendor.</source>
Expand Down
7 changes: 4 additions & 3 deletions src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.pl.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,10 @@ Błąd: {1}</target>
<note></note>
</trans-unit>
<trans-unit id="UTA_ExecuteThrewException">
<source>Exception thrown while executing test. If using extension of TestMethodAttribute then please contact vendor. Error message: {0}, Stack trace: {1}</source>
<target state="translated">Zgłoszono wyjątek podczas wykonywania testu. W przypadku korzystania z rozszerzenia atrybutu TestMethodAttribute należy skontaktować się z dostawcą. Komunikat o błędzie: {0}, ślad stosu: {1}</target>
<note></note>
<source>An unhandled exception was thrown by the 'Execute' method. Please report this error to the author of the attribute '{0}'.
{1}</source>
<target state="needs-review-translation">Zgłoszono wyjątek podczas wykonywania testu. W przypadku korzystania z rozszerzenia atrybutu TestMethodAttribute należy skontaktować się z dostawcą. Komunikat o błędzie: {0}, ślad stosu: {1}</target>
<note />
</trans-unit>
<trans-unit id="UTA_NoTestResult">
<source>Error in executing test. No result returned by extension. If using extension of TestMethodAttribute then please contact vendor.</source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,10 @@ Erro: {1}</target>
<note></note>
</trans-unit>
<trans-unit id="UTA_ExecuteThrewException">
<source>Exception thrown while executing test. If using extension of TestMethodAttribute then please contact vendor. Error message: {0}, Stack trace: {1}</source>
<target state="translated">Exceção lançada durante a execução do teste. Se estiver usando a extensão de TestMethodAttribute, entre em contato com o fornecedor. Mensagem de erro: {0}, rastreamento de pilha: {1}</target>
<note></note>
<source>An unhandled exception was thrown by the 'Execute' method. Please report this error to the author of the attribute '{0}'.
{1}</source>
<target state="needs-review-translation">Exceção lançada durante a execução do teste. Se estiver usando a extensão de TestMethodAttribute, entre em contato com o fornecedor. Mensagem de erro: {0}, rastreamento de pilha: {1}</target>
<note />
</trans-unit>
<trans-unit id="UTA_NoTestResult">
<source>Error in executing test. No result returned by extension. If using extension of TestMethodAttribute then please contact vendor.</source>
Expand Down
7 changes: 4 additions & 3 deletions src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.ru.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,10 @@ Error: {1}</source>
<note></note>
</trans-unit>
<trans-unit id="UTA_ExecuteThrewException">
<source>Exception thrown while executing test. If using extension of TestMethodAttribute then please contact vendor. Error message: {0}, Stack trace: {1}</source>
<target state="translated">При выполнении теста возникло исключение. Если используется расширение атрибута TestMethodAttribute, обратитесь к поставщику. Сообщение об ошибке: {0}. Трассировка стека: {1}</target>
<note></note>
<source>An unhandled exception was thrown by the 'Execute' method. Please report this error to the author of the attribute '{0}'.
{1}</source>
<target state="needs-review-translation">При выполнении теста возникло исключение. Если используется расширение атрибута TestMethodAttribute, обратитесь к поставщику. Сообщение об ошибке: {0}. Трассировка стека: {1}</target>
<note />
</trans-unit>
<trans-unit id="UTA_NoTestResult">
<source>Error in executing test. No result returned by extension. If using extension of TestMethodAttribute then please contact vendor.</source>
Expand Down
7 changes: 4 additions & 3 deletions src/Adapter/MSTest.TestAdapter/Resources/xlf/Resource.tr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,10 @@ Hata: {1}</target>
<note></note>
</trans-unit>
<trans-unit id="UTA_ExecuteThrewException">
<source>Exception thrown while executing test. If using extension of TestMethodAttribute then please contact vendor. Error message: {0}, Stack trace: {1}</source>
<target state="translated">Test yürütülürken özel durum oluşturuldu. TestMethodAttribute uzantısını kullanıyorsanız lütfen satıcıyla iletişime geçin. Hata mesajı: {0}, Yığın izleme: {1}</target>
<note></note>
<source>An unhandled exception was thrown by the 'Execute' method. Please report this error to the author of the attribute '{0}'.
{1}</source>
<target state="needs-review-translation">Test yürütülürken özel durum oluşturuldu. TestMethodAttribute uzantısını kullanıyorsanız lütfen satıcıyla iletişime geçin. Hata mesajı: {0}, Yığın izleme: {1}</target>
<note />
</trans-unit>
<trans-unit id="UTA_NoTestResult">
<source>Error in executing test. No result returned by extension. If using extension of TestMethodAttribute then please contact vendor.</source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,10 @@ Error: {1}</source>
<note></note>
</trans-unit>
<trans-unit id="UTA_ExecuteThrewException">
<source>Exception thrown while executing test. If using extension of TestMethodAttribute then please contact vendor. Error message: {0}, Stack trace: {1}</source>
<target state="translated">执行测试时引发了异常。如果使用的是扩展 TestMethodAttribute,请与供应商联系。错误消息: {0},堆栈跟踪: {1}</target>
<note></note>
<source>An unhandled exception was thrown by the 'Execute' method. Please report this error to the author of the attribute '{0}'.
{1}</source>
<target state="needs-review-translation">执行测试时引发了异常。如果使用的是扩展 TestMethodAttribute,请与供应商联系。错误消息: {0},堆栈跟踪: {1}</target>
<note />
</trans-unit>
<trans-unit id="UTA_NoTestResult">
<source>Error in executing test. No result returned by extension. If using extension of TestMethodAttribute then please contact vendor.</source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,10 @@ Error: {1}</source>
<note></note>
</trans-unit>
<trans-unit id="UTA_ExecuteThrewException">
<source>Exception thrown while executing test. If using extension of TestMethodAttribute then please contact vendor. Error message: {0}, Stack trace: {1}</source>
<target state="translated">執行測試時擲回例外狀況。如果您使用 TestMethodAttribute 的擴充功能,請連絡廠商。錯誤訊息: {0},堆疊追蹤: {1}</target>
<note></note>
<source>An unhandled exception was thrown by the 'Execute' method. Please report this error to the author of the attribute '{0}'.
{1}</source>
<target state="needs-review-translation">執行測試時擲回例外狀況。如果您使用 TestMethodAttribute 的擴充功能,請連絡廠商。錯誤訊息: {0},堆疊追蹤: {1}</target>
<note />
</trans-unit>
<trans-unit id="UTA_NoTestResult">
<source>Error in executing test. No result returned by extension. If using extension of TestMethodAttribute then please contact vendor.</source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,12 @@ public void ExecuteForTestThrowingExceptionShouldReturnUnitTestResultWithFailedO

UnitTestResult[] results = testMethodRunner.Execute(string.Empty, string.Empty, string.Empty, string.Empty).ToUnitTestResults();
Verify(results[0].Outcome == AdapterTestOutcome.Failed);
Verify(results[0].ErrorMessage.Contains("Exception thrown while executing test"));
Verify(results[0].ErrorMessage.StartsWith(
"""
An unhandled exception was thrown by the 'Execute' method. Please report this error to the author of the attribute 'Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute'.
System.Exception: DummyException
""",
StringComparison.Ordinal));
}

public void ExecuteForPassingTestShouldReturnUnitTestResultWithPassedOutcome()
Expand Down Expand Up @@ -139,7 +144,12 @@ public void RunTestMethodForTestThrowingExceptionShouldReturnUnitTestResultWithF

UnitTestResult[] results = testMethodRunner.RunTestMethod().ToUnitTestResults();
Verify(results[0].Outcome == AdapterTestOutcome.Failed);
Verify(results[0].ErrorMessage.Contains("Exception thrown while executing test"));
Verify(results[0].ErrorMessage.StartsWith(
"""
An unhandled exception was thrown by the 'Execute' method. Please report this error to the author of the attribute 'Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute'.
System.Exception: Dummy Exception
""",
StringComparison.Ordinal));
}

public void RunTestMethodForMultipleResultsReturnMultipleResults()
Expand Down