Tests session does not end Rider - unit-testing

I am using Rider on Mac version 2021.1.2 and what I noticed is that when I run tests UniTest window for rider, there are times when even after tests are done executing, rider does not close session and the session is on forever.
Clicking stop on the session does not respond
The only way I found to get out of this situation is to close the Rider App.
I have been using Rider for a while and I have not seen this behavior before. Attaching a screen shot for the reference[
Is it a Rider bug or if there is anything I can do to deal with this?

There is a mechanism in Rider/ReSharper which detects that the test runner or dotnet process runs indefinitely due to different reasons. It shows you the following dialog in such cases:
If you don't get this dialog, check the selected options for If the ... process does not exit after settings on the Preferences/Settings | Build, Execution, Deployment | Unit Testing | Test Runner page.

Related

dbg gets extremely slow (during import of large drawing files)

in a very specific C++ environment (an application to analyse CAD-drawings), dbg becomes extremely slow when I try to import large drawings....
In this test environment I integrated GoogleTest/GoogleMock testing framework to manage the test results and extract relevant (debug) data, and do the JNI mocking to be able to test without the Java EE "counterpart" of the application.
For 1 specific drawing the processing is grossly delayed, in another case the dbg application itself seems to be "frozen" indefinitely. It reacts on no signal whatsoever anymore: if you press the "termination" button in the toolbar of the debug console (the "red square"), the message: "Termination Failed" appears. I eventually shut it down by terminating the debug thread.
When I run this "drawing import" WITHOUT debug (so just "run"), all is processed in about 15-20 seconds (and no catatonic behaviour of the environment).
In this configuration, the application runs on Linux (within a VirtualBox within a Windows environment)
....
Question: what could be the case here? I tried to extract some relevant info but dbg gives nothing away. Any bright idea's?
Thank you in advance.

When using ASSERT_DEATH, is there a way to automatically continue the execution of all tests once the application terminates?

I have a unit test that exercises code in such a way that it causes an assertion to fail. When an assertion fails, it is expected that the application finishes.
To test that this actually happens, I am using EXPECT_DEATH, and it works.
The code execution reaches the assertion line
The assertion fails
The program finishes
The test is passed
The problem is that when the program finishes, there is a window reporting that the program stopped working and I need to click "Close the program" for the tests to continue.
I'd need this window not to pop up at all and that the test continue without the need to press any button. Is this possible?
I am using GCC on MS Windows.
In Windows you can disable the Windows Error Reporting feature, which let the unwanted windows pop up. The bad news is that this needs to be done differently in different Windows versions. But the good news is that there are good people out there in the net, who have documented it quite well :) E.g. https://www.lifewire.com/how-do-i-disable-error-reporting-in-windows-2626074.

How to debug ember-cli tests running in phantomjs

Context: I have an acceptance test for my ember-cli application, and the test passes just fine in Chrome. However, in phantomjs, my test fails -- the UI doesn't get created the same way, and I'm trying to work out why. (I think the test is broken because of https://github.com/ember-cli/ember-cli/issues/1763, but the general question of how to debug remains)
In Chrome, I can use the standard debugging tools on my tests and all is well -- but in phantomjs, I can't get at it with a debugger. I also don't see console.log() messages show up in the output -- all I get is a list of test results in my terminal window.
I can sort-of get diagnostic info by writing things like
equal(true, false, "This is a log message");
and then I get the message as details for the assertion that failed, or I can try and work out what's in the DOM with
equal(true, false, document.getElementsByClassName("my-class".innerHTML);
but both of those a:stop the test going any further, and b:only let me log information from the test itself, not my application.
Is there a way to run my tests outside of "ember test", or some way to attach to the running test processes? Alternatively, is there a way to get console.log() messages to show up in the output?
You can expose PhantomJS debug port and open it in browser then you can interact with context at your debugger breakpoints.
Debugging tests on PhantomJS using Testem test runner
In testem.json add "phantomjs_debug_port": 9000.
While you run your tests visit http://localhost:9000 in your browser and click the long link that shows up.
Source: cssugared
I had no luck with the other answers, so here's what I found out:
Add a return pauseTest(); at the point in your test where you want to be able to interact with the container in the browser. This is in the docs but I'm not sure it's in the guides.
To answer the part of my original question about "how do I get log messages to show up", if I use the TAP reporter, then console.log (in my app and in my tests) messages show up in the output; the xunit reporter doesn't pass console.log on, which was confusing me.
(I've also hit issues where running the tests on teamcity behaves differently than running locally; in that situation, combining the TAP reporter with https://github.com/aghassemi/tap-xunit (or the TAP teamcity plugin) lets me get log messages and also test counts)

Failed unit tests always show succeed notification when tested on device in XCode 6 beta swift

Unit tests always show 'succeed' desktop notification when run on device in XCode 6 beta 6 in Swift.
How to recreate:
Create new iOS single-view app project with Swift.
Go to the existing test and change it to XCTAssert(false) to make it fail.
Run the tests on the device - it shows "Test Succeeded" desktop notification.
Run the test on the emulator - it shows "Test Failed" notification as it should.
Update
There are test error messages in the output window when testing on device. But the desktop notification says "Test Succeeded".
When I test on device and set a breakpoint in the test method - it does stop there.
Run the test on the emulator - it shows "Test Failed" notification as it should.
Copied from the Question, in case someone doesn't realize there is a way to get them to work (although not on device).
(may be helps to someone who will face same issue later)
I made my custom XCTestCase class and test methods in it as Private, following which Xcode wasn't running that test cases and class and was showing "all tests succeeded" output.
Removing Private solved problem.

Testing running condition of a Windows app

I have several applications that are part of a suite of tools that various developers at our studio use. these applications are mainly command line apps that open a DOS cmd shell. These apps in turn start up a GUI application that tracks output and status (via sockets) of these command line apps.
The command line apps can be started with the user is logged in, when their workstation is locked (they fire off a batch file and then immediately lock their workstation), and when they are logged out (via a scheduled task). The problems that I have are with the last two cases.
If any of these apps fire off when the user is locked or logged out, these command will spawn the GUI windows which tracks the output/status. That's fine, but say the user has their workstation locked -- when they unlock their workstation, the GUI isn't visible. It's running the task list, but it's not visible. The next time these users run some of our command line apps, the GUI doesn't get launched (because it's already running), but because it's not visible on the desktop, users don't see any output.
What I'm looking for is a way to tell from my command line apps if they are running behind a locked workstation or when a user is logged out (via scheduled task) -- basically are they running without a user's desktop visible. If I can tell that, then I can simply not start up our GUI and can prevent a lot of problem.
These apps that I need to test are C/C++ Windows applications.
I hope that this make sense.
I found the programmatic answer that I was looking for. It has to do with stations. Apparently anything running on the desktop will run on a station with a particular name. Anything that isn't on the desktop (i.e. a process started by the task manager when logged off or on a locked workstation) will get started with a different station name. Example code:
HWINSTA dHandle = GetProcessWindowStation();
if ( GetUserObjectInformation(dHandle, UOI_NAME, nameBuffer, bufferLen, &lenNeeded) ) {
if ( stricmp(nameBuffer, "winsta0") ) {
// when we get here, we are not running on the real desktop
return false;
}
}
If you get inside the 'if' statement, then your process is not on the desktop, but running "somewhere else". I looked at the namebuffer value when not running from the desktop and the names don't mean much, but they are not WinSta0.
Link to the docs here.
You might be able to use SENS (System Event Notification Services). I've never used it myself, but I'm almost positive it will do what you want: give you notification for events like logon, logoff, screen saver, etc.
I know that's pretty vague, but hopefully it will get you started. A quick google search turned up this, among others: http://discoveringdotnet.alexeyev.org/2008/02/sens-events.html
I have successfully used this approach to detect whether the desktop is locked on Windows:
bool isDesktopLocked = false;
HDESK inputDesktop = OpenInputDesktop(0, FALSE,
DESKTOP_CREATEMENU | DESKTOP_CREATEWINDOW |
DESKTOP_ENUMERATE | DESKTOP_SWITCHDESKTOP |
DESKTOP_WRITEOBJECTS | DESKTOP_READOBJECTS |
DESKTOP_WRITE);
if (NULL == inputDesktop)
{
isDesktopLocked = true;
}
else
{
CloseDesktop(inputDesktop);
}