reportportal / agent-net-vstest

Logger extension for VsTest
Apache License 2.0
8 stars 10 forks source link

Run Tests from VSTS Error: Could not find a test logger with URI or FriendlyName 'ReportPortal'. Error: The parameter "/TestAdapterPath" should be provided only once. #17

Closed heilwood closed 5 years ago

heilwood commented 5 years ago

Hi,

I'm using simple .net framework application with automatic tests and CI tool VSTS, im trying to run tests with following command as Other console options: /TestAdapterPath:. /Logger:ReportPortal And next error appears:

Could not find a test logger with URI or FriendlyName 'ReportPortal'.
Error: The parameter "/TestAdapterPath" should be provided only once.

I found instructions for dotnet core application how to fix this using dotnet publish, but nothing was said about .net framework

Any suggestion how to fix this?

nvborisenko commented 5 years ago

@heilwood please provide full console output including version of runner.

Also what version of ReportPortal.VSTest.TestLogger are you using?

heilwood commented 5 years ago

@nvborisenko ReportPortal.VSTest.TestLogger version 1.30. Runner Version:2.147.0, here is the log:

##[section]Starting: Test Run ============================================================================== Task : Visual Studio Test Description : Version : 2.147.0 Author : Microsoft Corporation Help : [More information](https://go.microsoft.com/fwlink/?LinkId=835764) ============================================================================== SystemVssConnection exists true SystemVssConnection exists true SystemVssConnection exists true Running tests using vstest.console.exe runner. ====================================================== Test selector : Test assemblies Test filter criteria : null Search folder : C:\ag\_work\4\s VisualStudio version selected for test execution : latest Run in parallel : false Run in isolation : false Path to custom adapters : null Other console options : /Logger:ReportPortal Code coverage enabled : false Diagnostics enabled : false SystemVssConnection exists true Run the tests locally using vstest.console.exe ======================================================== Test selector : Test assemblies Test assemblies : **\Remote\*RM.Automation*.dll,!**\obj\** Test filter criteria : null Search folder : C:\ag\_work\4\s Run settings file : C:\ag\_work\4\s Run in parallel : false Run in isolation : false Path to custom adapters : null Other console options : /Logger:ReportPortal Code coverage enabled : false Diagnostics enabled : false Rerun failed tests: false VisualStudio version selected for test execution : latest ======================================================== ====================================================== [command]"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" @C:\ag\_work\_temp\647ba4e1-4655-11e9-9fd1-9d010a0beb54.txt Microsoft (R) Test Execution Command Line Tool Version 15.0.26228.0 Copyright (c) Microsoft Corporation. All rights reserved. ` vstest.console.exe "C:\ag_work\4\s\Horinzon.RM.Automation\bin\Remote.Automation.dll" /logger:"trx" /TestAdapterPath:"C:\ag_work\4\s" /Logger:ReportPortal Error: Could not find a test logger with URI or FriendlyName 'ReportPortal'. ##[warning]Vstest failed with error. Check logs for failures. There might be failed tests. ##[error]Error: The process 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe' failed with exit code 1 ##[warning]No results found to publish. ##[error]VsTest task failed. ##[section]Finishing: Test Run `

nvborisenko commented 5 years ago

Try to not specify TestAdapterPath in console arguments. Vstest does it automatically and finds logger in the folder where your test assembly is located.

Also, I saw you use SpecFlow as test framework, you might be interested in agent for SpecFlow.

heilwood commented 5 years ago

Thank you for suggestion, but specflow plugin have some restrictions, like we need to use shared App Domain, is not our case. Without test adapter options:

[command]"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" @C:\ag\_work\_temp\647ba4e1-4655-11e9-9fd1-9d010a0beb54.txt Microsoft (R) Test Execution Command Line Tool Version 15.0.26228.0 Copyright (c) Microsoft Corporation. All rights reserved. ` vstest.console.exe "C:\ag_work\4\s\Automation\bin\Remote\Automation.dll" /logger:"trx" /TestAdapterPath:"C:\ag_work\4\s" /Logger:ReportPortal Error: Could not find a test logger with URI or FriendlyName 'ReportPortal'. ##[warning]Vstest failed with error. Check logs for failures. There might be failed tests. ##[error]Error: The process 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe' failed with exit code 1 ##[warning]No results found to publish. ##[error]VsTest task failed. ##[section]Finishing: Test Run `

nvborisenko commented 5 years ago

Runner cannot find logger because this version (15.0) of runner finds loggers in the current directory. You can specify the full path to the logger (bin/debug) where ReportPortal.VsTest.TestLogger.dll is located, or use the newest version of runner. When I use Latest version of Test Platform in vsts task, it uses 15.9, which is smart enough.

I would recommend to use Visual Studio Test Platform Installer task in pipeline to install Test Platform with specific version (usually latest), and use it in Visual Studio Test task. Screenshot_2

heilwood commented 5 years ago

Run with you suggestion:

##[section]Starting: Test Run ============================================================================== Task : Visual Studio Test Version : 2.147.0 Author : Microsoft Corporation Help : [More information](https://go.microsoft.com/fwlink/?LinkId=835764) ============================================================================== SystemVssConnection exists true SystemVssConnection exists true SystemVssConnection exists true Running tests using vstest.console.exe runner. ====================================================== Test selector : Test assemblies Test filter criteria : null Search folder : C:\ag\_work\4\s Run in parallel : false Run in isolation : false Path to custom adapters : null Other console options : /Logger:ReportPortal Code coverage enabled : false Diagnostics enabled : false SystemVssConnection exists true Run the tests locally using vstest.console.exe ======================================================== Test selector : Test assemblies Test assemblies : **\Remote\*RM.Automation*.dll,!**\obj\** Test filter criteria : null Search folder : C:\ag\_work\4\s Run settings file : C:\ag\_work\4\s Run in parallel : false Run in isolation : false Path to custom adapters : null Other console options : /Logger:ReportPortal Code coverage enabled : false Diagnostics enabled : false Rerun failed tests: false VisualStudio version selected for test execution : toolsInstaller ======================================================== ====================================================== [command]C:\ag\_work\_tool\VsTest\15.9.0\x64\tools\net451\Common7\IDE\Extensions\TestPlatform\vstest.console.exe @C:\ag\_work\_temp\5c1f8eb1-4718-11e9-8e79-297a82dcd103.txt Microsoft (R) Test Execution Command Line Tool Version 15.9.0 Copyright (c) Microsoft Corporation. All rights reserved. ` vstest.console.exe "C:\ag_work\4\s\Automation\bin\Remote.Automation.dll" /logger:"trx" /TestAdapterPath:"C:\ag_work\4\s" /Logger:ReportPortal Starting test execution, please wait... Could not find a test logger with AssemblyQualifiedName, URI or FriendlyName 'ReportPortal'. ##[warning]Vstest failed with error. Check logs for failures. There might be failed tests. ##[error]Error: The process 'C:\ag_work_tool\VsTest\15.9.0\x64\tools\net451\Common7\IDE\Extensions\TestPlatform\vstest.console.exe' failed with exit code 1 ##[warning]No results found to publish. ##[error]VsTest task failed. ##[section]Finishing: Test Run `

With Latest version the same.

Run with /ListLogger option:

/ListLoggers The following Test Logger Add-Ins are available: Microsoft.TestPlatform.Extensions.BlameDataCollector.BlameLogger Uri: logger://Microsoft/TestPlatform/Extensions/Blame/v1 FriendlyName: Blame Microsoft.VisualStudio.TestPlatform.Extensions.TrxLogger.TrxLogger Uri: logger://Microsoft/TestPlatform/TrxLogger/v1 FriendlyName: Trx ##[warning]No results found to publish. ##[section]Finishing: Test Run

heilwood commented 5 years ago

image

This is my pipeline config steps

nvborisenko commented 5 years ago

When you build your project, do you see ReportPortal.VsTest.TestLogger.dll file in output directory (bin/debug)? And ReportPortal.config.json file?

heilwood commented 5 years ago

Yes, it is in bin folder but name of the folder is not debug i'm using different name of configuration (local and remote).

image

nvborisenko commented 5 years ago

Does it work locally?

Let's try to execute tests on VSTS with /Diag:MyLog.txt. Then let's see logs.

heilwood commented 5 years ago

MyLog.txt

Don't know how to test this locally.

nvborisenko commented 5 years ago

What is your .net target framework?

heilwood commented 5 years ago

.NET Framework 4.6.1

nvborisenko commented 5 years ago

Could you please upgrade package to ReportPortal.VSTest.TestLogger 2.0.0-beta.4 and execute vsts job again?

heilwood commented 5 years ago

Build finished with no errors. Trying to get results into reportportal, looks like with json something wrong, but currently cannot figure out. Thank you for help, you are doing really great job!

nvborisenko commented 5 years ago

Ensure in console output you have something like "Results are sent to ReportPortal".

Find your results on "Debug" tab in RP. image Can be configured in json file - debug property.

heilwood commented 5 years ago

Such error found in log:

  1. Error: TpTrace Error: 0 : 7324, 3, 2019/03/15, 14:06:40.942, 14052382115029, vstest.console.exe, InternalTestLoggerEvents.SendTestResult: Exception occurred while calling handler of type ReportPortal.VSTest.TestLogger.ReportPortalLogger for TestResultEventArgs: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object. at ReportPortal.VSTest.TestLogger.ReportPortalLogger.Events_TestResult(Object sender, TestResultEventArgs e) --- End of inner exception stack trace --- at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) at System.Delegate.DynamicInvokeImpl(Object[] args) at Microsoft.VisualStudio.TestPlatform.Utilities.MulticastDelegateUtilities.SafeInvoke(Delegate delegates, Object sender, EventArgs args, String traceDisplayName) TpTrace Error: 0 : 7324, 3, 2019/03/15, 14:06:40.942, 14052382148185, vstest.console.exe, InternalTestLoggerEvents.SendTestResult: Exception occurred while calling handler of type ReportPortal.VSTest.TestLogger.ReportPortalLogger for TestResultEventArgs: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object. at ReportPortal.VSTest.TestLogger.ReportPortalLogger.Events_TestResult(Object sender, TestResultEventArgs e) --- End of inner exception stack trace --- at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) at System.Delegate.DynamicInvokeImpl(Object[] args) at Microsoft.VisualStudio.TestPlatform.Utilities.MulticastDelegateUtilities.SafeInvoke(Delegate delegates, Object sender, EventArgs args, String traceDisplayName)

  2. Error: TpTrace Error: 0 : 7324, 3, 2019/03/15, 14:06:48.606, 14052458866824, vstest.console.exe, InternalTestLoggerEvents.SendTestRunComplete: Exception occurred while calling handler of type ReportPortal.VSTest.TestLogger.ReportPortalLogger for TestRunCompleteEventArgs: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: The tasks argument included a null value. Parameter name: tasks at System.Threading.Tasks.TaskFactory.CheckMultiContinuationTasksAndCopy(Task[] tasks) at System.Threading.Tasks.TaskFactory1.ContinueWhenAllImpl(Task[] tasks, Func2 continuationFunction, Action1 continuationAction, TaskContinuationOptions continuationOptions, CancellationToken cancellationToken, TaskScheduler scheduler, StackCrawlMark& stackMark) at System.Threading.Tasks.TaskFactory.ContinueWhenAll[TResult](Task[] tasks, Func2 continuationFunction) at ReportPortal.Shared.Reporter.TestReporter.Finish(FinishTestItemRequest request) at ReportPortal.VSTest.TestLogger.ReportPortalLogger.Events_TestRunComplete(Object sender, TestRunCompleteEventArgs e) --- End of inner exception stack trace --- at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) at System.Delegate.DynamicInvokeImpl(Object[] args) at Microsoft.VisualStudio.TestPlatform.Utilities.MulticastDelegateUtilities.SafeInvoke(Delegate delegates, Object sender, EventArgs args, String traceDisplayName)

My json:

{ "$schema": "https://raw.githubusercontent.com/reportportal/agent-net-vstest/master/ReportPortal.VSTest.TestLogger/ReportPortal.config.schema", "enabled": true, "server": { "url": "http://myhost:8080/api/v1/", "project": "superadmin_personal", "authentication": { "uuid": "74c2b0f9-90f4-474f-bcaf-52fb48249ce6" } }, "launch": { "name": "superadmin_TEST_EXAMPLE", "description": "this is description", "debugMode": true, "tags": ["t1", "t2"] } }

nvborisenko commented 5 years ago

I guess the initial issue can be considered as resolved in v2.0.0. Please create another issue for problem above.

heilwood commented 5 years ago

working only on 15.9.0 vstest version, on 15.9.1 and latest version i have same error.

nvborisenko commented 5 years ago

Fixed in #18