2016-04-06 2 views
0

Недавно я начал строить свои проекты C# на сервере сборки Jenkins.NUnit Test on Jenkins fail (файл результатов nunit xml пуст)

Но в последнее время я была проблема, что сообщенная NUnit XML является пустой (файл создается, но не имеет никакого содержания.)

выхода консоль выглядит следующим образом

Process leaked file descriptors. See http://wiki.jenkins-ci.org/display/JENKINS/Spawning+processes+from+build for more information [WARNINGS] Parsing warnings in console log with parser MSBuild [WARNINGS] Computing warning deltas based on reference build #288 Recording NUnit tests results ERROR: Step ‘Publish NUnit test result report’ aborted due to exception: hudson.util.IOException2: Could not transform the NUnit report. Please report this issue to the plugin author at hudson.plugins.nunit.NUnitArchiver.invoke(NUnitArchiver.java:65) at hudson.plugins.nunit.NUnitArchiver.invoke(NUnitArchiver.java:26) at hudson.FilePath.act(FilePath.java:990) at hudson.FilePath.act(FilePath.java:968) at hudson.plugins.nunit.NUnitPublisher.perform(NUnitPublisher.java:145) at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20) at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:782) at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:723) at hudson.model.Build$BuildExecution.post2(Build.java:185) at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:668

я знаю, что проблема есть вероятно, пропущенные файловые дескрипторы, но я не совсем уверен, как это исправить.

NUnit тесты выполнены с Powershell скрипт, который захватывает все необходимые DLLS

Powershell скрипт:

param(
[string] $sourceDirectory = "./trunk/TestProjects/" 
, $fileFilters = @("*UnitTest*.dll") 
, [string]$filterText = "*\bin*" 
) 

#script that executes all unit tests available. 


Write-Host "Source: $sourceDirectory" 
Write-Host "File Filters: $fileFilters" 
Write-Host "Filter Text: $filterText" 

$cFiles = "" 
$nUnitExecutable = "C:\Program Files (x86)\NUnit.org\nunit-console\nunit3-console.exe" 

# look through all subdirectories of the source folder and get any unit test assemblies. To avoid duplicates, only use the assemblies in the bin folder 
[array]$files = get-childitem $sourceDirectory -include $fileFilters -recurse | select -expand FullName | where {$_ -like $filterText} 

foreach ($file in $files) 
{ 
    $cFiles = $cFiles + '"' + $file + '"' + " " 
} 

# set all arguments and execute the unit console 
$argumentList = @("$cFiles", "--result=nunit-result.xml;format=nunit2","--framework=net-4.5","--process=Single") 

$unitTestProcess = start-process -filepath $nUnitExecutable -argumentlist $argumentList -nonewwindow 
echo "$nUnitExecutable $argumentList" 


$exitCode = $unitTestProcess.ExitCode 

exit $exitCode 

эта проблема возникает только, если скрипт выполняется с помощью Jenkins

# ############### UPDATE

после некоторого расследования я узнал, что его происходит только тогда, когда я добавляю 1 тестовый файл, в котором wpf con троллей создаются путем вызова их в потоке пользовательского интерфейса.

 [Test Apartment(ApartmentState.STA) RunInApplicationDomain] 
    public void CheckPluginModel() 
    { 
     var app = Application.Current ?? new Application { ShutdownMode = ShutdownMode.OnExplicitShutdown }; 
     PluginModel model = new PluginModel(); 

     var task= model.LoadPluginsFromPath(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)); 


     RunApplication(() => task.IsCompleted); 


     Assert.That(model.AvailablePluginControls.Count, Is.EqualTo(1)); 
     Assert.That(model.Workflows.Count, Is.EqualTo(1)); 
     Console.WriteLine("Plugin model check finished"); 

    } 

RunApplication:

 /// <summary> 
    /// Runs the application. as long as abortCriteria returns false 
    /// </summary> 
    /// <param name="abortCriteria">The abort criteria.</param> 
    private void RunApplication(Func<bool> abortCriteria, int duetime = 100, int period=100) 
    { 

     Console.WriteLine("Application started"); 
     System.Threading.Timer timer = null; 
     timer = new Timer((obj) => 
     { 
      if (abortCriteria.Invoke()) 
      { 
       Application.Current.Dispatcher.Invoke(() => Application.Current.Shutdown()); 
       timer.Dispose(); 

      } 
     }, null, duetime, period); 

     Application.Current.Run(); 

     Console.WriteLine("Application stopped"); 
    } 

Все элементы графического интерфейса созданы

await Application.Current.Dispatcher.BeginInvoke(new Action(() => AvailablePluginControls.Add((APControl)Activator.CreateInstance(item))),null); 
+0

У вас действительно есть прав для записи файла в конкретный каталог? – Vitalliuss

+0

Да, сам файл создан, но не имеет содержимого; – Markus

ответ

0

Проблема заключалась в том, как следует:

Испытания блока выполняются с помощью сценария Powershell. Процесс запуска powershell не дожидается, пока процесс не завершится. Это приводит к тому, что дочерний процесс не завершен.

для того, чтобы начать процесс, чтобы дождаться завершения процесса, необходимо добавить флаг -Wait.

-1

Nunit плагин в Дженкинс не поддерживает Nunit 3 формат XML. Я также похожа на проблему Дженкинса. Я использовал для преобразования формата результата Nunit 3 в формат Nunit 2.

"C:\NUnit 3.5.0\nunit3-console.exe" /result:\MyApplication.xml;format=nunit2 "D:\Jenkins\workspace\MyApplication.Tests.dll"

+0

отформатируйте свой ответ –

Смежные вопросы