This is an automated email from the ASF dual-hosted git repository.

paulirwin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucenenet.git


The following commit(s) were added to refs/heads/master by this push:
     new b28fa344f Improve message for unit test failures for 
lucene.testsettings.json, #999 (#1021)
b28fa344f is described below

commit b28fa344f7c0788315ced770f329858745da1df0
Author: Paul Irwin <[email protected]>
AuthorDate: Wed Nov 13 07:28:22 2024 -0700

    Improve message for unit test failures for lucene.testsettings.json, #999 
(#1021)
---
 .../Util/LuceneTestCase.cs                         | 53 ++++++++++++++++------
 1 file changed, 38 insertions(+), 15 deletions(-)

diff --git a/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs 
b/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
index 210aa689a..d3c7ec691 100644
--- a/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
+++ b/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
@@ -929,23 +929,46 @@ namespace Lucene.Net.Util
                 */
 
             TestResult result = 
TestExecutionContext.CurrentContext.CurrentResult;
-            string message;
+
             if (result.ResultState == ResultState.Failure || 
result.ResultState == ResultState.Error)
             {
-                message = result.Message + $"\n\nTo reproduce this test 
result:\n\n" +
-                    $"Option 1:\n\n" +
-                    $" Apply the following assembly-level attributes:\n\n" +
-                    $"[assembly: 
Lucene.Net.Util.RandomSeed(\"{RandomizedContext.CurrentContext.RandomSeedAsHex}\")]\n"
 +
-                    $"[assembly: 
NUnit.Framework.SetCulture(\"{Thread.CurrentThread.CurrentCulture.Name}\")]\n\n"
 +
-                    $"Option 2:\n\n" +
-                    $" Use the following .runsettings file:\n\n" +
-                    $"<RunSettings>\n" +
-                    $"  <TestRunParameters>\n" +
-                    $"    <Parameter name=\"tests:seed\" 
value=\"{RandomizedContext.CurrentContext.RandomSeedAsHex}\" />\n" +
-                    $"    <Parameter name=\"tests:culture\" 
value=\"{Thread.CurrentThread.CurrentCulture.Name}\" />\n" +
-                    $"  </TestRunParameters>\n" +
-                    $"</RunSettings>\n\n" +
-                    $"See the .runsettings documentation at: 
https://docs.microsoft.com/en-us/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file.";;
+                string message =
+                    $$"""
+                      {{result.Message}}
+
+                      To reproduce this test result:
+
+                      Option 1:
+
+                       Apply the following assembly-level attributes:
+
+                      [assembly: 
Lucene.Net.Util.RandomSeed("{{RandomizedContext.CurrentContext.RandomSeedAsHex}}")]
+                      [assembly: 
NUnit.Framework.SetCulture("{{Thread.CurrentThread.CurrentCulture.Name}}")]
+
+                      Option 2:
+
+                       Use the following .runsettings file:
+
+                      <RunSettings>
+                        <TestRunParameters>
+                          <Parameter name="tests:seed" 
value="{{RandomizedContext.CurrentContext.RandomSeedAsHex}}" />
+                          <Parameter name="tests:culture" 
value="{{Thread.CurrentThread.CurrentCulture.Name}}" />
+                        </TestRunParameters>
+                      </RunSettings>
+
+                      Option 3:
+
+                       Create the following lucene.testsettings.json file 
somewhere between the test assembly and the root of your drive:
+
+                      {
+                        "tests": {
+                           "seed": 
"{{RandomizedContext.CurrentContext.RandomSeedAsHex}}",
+                           "culture": 
"{{Thread.CurrentThread.CurrentCulture.Name}}"
+                        }
+                      }
+
+                      """;
+
                 result.SetResult(result.ResultState, message, 
result.StackTrace);
             }
         }

Reply via email to