question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add shared file logger implementation to the test framework

See original GitHub issue

We need a common logger implementation that would always log requests/responses into files that would be added as an artifact.

There should be one file per test invocation with the path something like:

Azure.Core/HttpClientTransportTests/SomeTestNameAsync.txt

This would allow us to get rid of multiple test logger implementations and always have some logs when a test unexpectedly fails without requiring someone to instrument the code.

cc @heaths @JoshLove-msft

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:19 (19 by maintainers)

github_iconTop GitHub Comments

1reaction
pakrymcommented, May 9, 2020

But always writing to Progress would make the output incredibly noisy. We can write to Out and a file at the same time though.

1reaction
JoshLove-msftcommented, May 9, 2020

So it is true that Debug.Assert(false) would cause the Test to not be marked as Passed or Failed, but the output is still there:

        [Test]
        public void DebugAssert()
        {
            TestContext.Progress.WriteLine("event output");
            Debug.Assert(false);
        }
event output
The active test run was aborted. Reason: Test host process crashed : Assertion Failed
   at Azure.Messaging.ServiceBus.Tests.Processor.SessionProcessorTests.DebugAssert() in C:\Users\jolov\source\repos\Azure\azure-sdk-for-net\sdk\servicebus\Azure.Messaging.ServiceBus\tests\Processor\SessionProcessorTests.cs:line 35
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at NUnit.Framework.Internal.Reflect.InvokeMethod(MethodInfo method, Object fixture, Object[] args) in D:\a\1\s\src\NUnitFramework\framework\Internal\Reflect.cs:line 266
   at NUnit.Framework.Internal.Commands.TestMethodCommand.Execute(TestExecutionContext context) in D:\a\1\s\src\NUnitFramework\framework\Internal\Commands\TestMethodCommand.cs:line 64
   at NUnit.Framework.Internal.Commands.TimeoutCommand.<>c__DisplayClass2_0.<Execute>b__0() in D:\a\1\s\src\NUnitFramework\framework\Internal\Commands\TimeoutCommand.cs:line 102
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to have one logger in every test case?
It does work but I am not sure if there is something better to have one common logger for every test case. Currently...
Read more >
Set up Log4j logging in Selenium Automation Framework
Step by step process to Set up Log4j Logging in Selenium Automation framework. Set up TestNG, Data Driven, POM, Modularity, Functional Libs ...
Read more >
How to implement a simple logger in C# | InfoWorld
C# logger classes​​ The next step is to design and implement the classes. We will use three distinct classes—namely, FileLogger , DBLogger ,...
Read more >
23 Slf4j - Log4j : Adding logging to your test framework
GitHub: https://github.com/PramodKumarYadav/zero Goals: 1. To add a logging interface in our test framework. 2. To add an actual logging ...
Read more >
Logger in Java | Java Logging Basics with Log4j and util
This article on Logger in Java is a comprehensive guide on the Java logging API used for logging solutions while creating projects.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found