Why does sbt exit while executing tests with no errors? - sbt

I've been using SBT to run unit tests on my code, and made some changes recently that have caused the tests to start acting weird.
None of the tests that I have seen fail, but when running the tests with sbt, it just stops in the middle and closes without giving an error message. There are no failed tests in the output.
Does anyone know why this might happen, or how I could figure out what the problem is?

Thanks to the comment by #johanandren, I managed to nail it down to an exception that was being thrown by forcing sbt to fork the tests in a new process. The exception was a java.io.EOFException disguised as an sbt out of memory error -- java.lang.OutOfMemoryError: PermGen space -- and increasing it using the -XX:MaxPermSize argument in the SBT_OPTS environment variable as described in SBT runs out of memory helped fix that issue.

Related

Appium Pagefactory throws noSuchMethodException when running from POM

When I try to run my appium scripts on the pom file ( with mvn verify or mvn test)
I get a
java.lang.RuntimeException: java.lang.NoSuchMethodException: jdk.proxy2.$Proxy12.proxyClassLookup()
On the line that instantiates my locators:
PageFactory.initElements(new AppiumFieldDecorator(driver, Duration.ofSeconds(15)), this);
When I run the test directly from InteliJ or run the testng.xml file, the test succeeds
Full pom.xml: https://pastebin.com/V0FbehMh
Full error stacktrace: https://pastebin.com/11TvTq7a
testng.xml: https://pastebin.com/8XZtCfRt
Related classes: https://pastebin.com/ynFizC9T
What can be the problem, when everything is fine running from test class / testng.xml, but suddenly failing when running with maven in command line
it's a bit embarrassing, (because i remembered I did this before)
After doing an mvn clean, and an mvn compile again,
Then the issue disappeared. something probably got stuck somewhere and needed a clean again..

Mocha coverage task fails and propagates exception to grunt which aborts the whole execution

I am using grunt-mocha-istanbul and have a task which runs the coverage through set of test files. The reporter is set to mocha-junit-reporter which generates the mocha test results XML file and the coverage report formats are set to cobertura and html.
For some reason, an error in the tests causes the whole task to fail and not just to get details on the failed test in the end report.
I ran the grunt task using --stack argument which produced the following:
Error: Task "mocha_istanbul:coveralls" failed.
at Task.<anonymous> (~\node_modules\grunt\lib\util\task.js:205:15)
at null._onTimeout (~\node_modules\grunt\lib\util\task.js:241:33)
at Timer.listOnTimeout (timers.js:92:15)
As you can see, this hides the original error somehow.
I defined a separate task to just run the tests and saw the issue but it has nothing to do with how the test execution in terms of callbacks gets handled.
So my question is, how can I intercept such propagated exceptions and provide more detailed information on what actually happened?

Release does not run. This application failed to start

My application works when it built in debug mode. But it does not run in release.
This application failed to start because it could not find or load the
Qt platform plugin "windows".
Reinstalling the application may fix this problem.
I copied dlls which the application required. I copied also qwindows.dll, qoffscreen.dll and libEGL.dll.
But libEGL.dll located in C:\qt\5.3\msvc2013\bin and `C:Qt\ToolsQtCreator\bin'. I compiled my application by msvc-11.0(2012).
--
I put platforms folder to exe directory and now application runs but crashes immediately in ntdll.dll!771e56bc()
Now my problem is similar to this one Why is ntdll.dll crashing my c++ executable?.
Can I make debug working like release but save debug mode?
--
Here is Application Verifier result for release mode. It does not happen for debug.
=======================================
VERIFIER STOP 00000006: pid 0xDF0: Corrupted heap pointer or using wrong heap.
00161000 : Heap handle used in the call.
093F8FF8 : Heap block involved in the operation.
00000004 : Size of the heap block.
06441000 : Heap where block was originally allocated.
=======================================
This verifier stop is not continuable. Process will be terminated
when you use the `go' debugger command.
=======================================
MyApp.exe has triggered a breakpoint.
AVRF: Noncontinuable verifier stop 00000006 encountered. Terminating process ...
The thread 0x1724 has exited with code -1073740767 (0xc0000421).
The program '[3568] MyApp.exe' has exited with code -1073740767 (0xc0000421).
--
Here is a top of a call stack
vrfcore.dll!6ae43466() Unknown
[Frames below may be incorrect and/or missing, no symbols loaded for vrfcore.dll]
[External Code]
qwindows.dll!0f0642cb() Unknown
qwindows.dll!0f065f8a() Unknown
qwindows.dll!0f0662bb() Unknown
Qt5Gui.dll!0f774cf3() Unknown
Qt5Gui.dll!0f774e75() Unknown
Qt5Gui.dll!0f7778d5() Unknown
But libEGL.dll located in C:\qt\5.3\msvc2013\bin and `C:Qt\ToolsQtCreator\bin'
You must not take any DLLs from C:\Qt\Tools\QtCreator\ -- these are private DLLs for Qt Creator, and they are incompatible with your application.
Only take DLLs from C:\Qt\5.3\msvc2013\bin and C:\Qt\5.3\msvc2013\plugins. Here is the required folder structure:
(source: http://qt-project.org/wiki/Deploy_an_Application_on_Windows )
This sounds like either a DLL is missing or the application expects it in a different path.
a) Use the Dependency Walker on your release build executable to check whether all DLL dependencies can be resolved.
b) Make sure that your platform plugin files are at the right location. I think they need to be in a folder called "platforms" (not absolutely sure though).
c) There is a post in the Qt forum about a similar problem. Maybe this helps you to track it down.

How to make SBT task fail and hence build itself?

I wrote a SBT task to run cssLint for my project using rhino. cssLint returns exit code to my SBT task.
My question is how to make the task fail if the exit code is non-zero?
I don't want to throw any exceptions. I want my last line of the task result to show [Failed] instead of [success] and exit code of my SBT task to be non-zero.
SAMPLE
MyTask {
val exitcode = //rhino functions
//what to do??
}
The actual intent is to fail the build if css errors are present.
The way of failing the build without producing the stacktrace on the console is using the exceptions that are specifically handled:
for sbt.MessageOnlyException an error message is logged twice (without task name and then with task name) and the build is stopped
mix in sbt.FeedbackProvidedException or sbt.UnprintableException to implement custom exceptions for which sbt does not print a stacktrace. The string with task name and exception's toString is logged on the top level once and the build is stopped. It is expected that essential information for the user is already logged before throwing these.
Disclaimer: I've not seen this information in sbt manual. Extracted from the sources of sbt 0.13.16. sbt.FeedbackProvidedException is used this way by sbt compiler, sbt tests and by sbt-web and Play sbt plugins.
My understanding is that the success message is printed out always unless
showSuccess setting is set to false or
a task throws an exception.
In your particular case you want to report an error and so you should throw an exception or a value of the type of the result that might be considered a sort of exception like None or Failure.
Say, you've got the following task defined in build.sbt:
lazy val tsk = taskKey[Unit]("Task that always fails")
tsk := {
throw new IllegalStateException("a message")
}
When you execute the tsk task, the exception is printed out with no [success] afterwards.
[no-success]> tsk
[trace] Stack trace suppressed: run last *:tsk for the full output.
[error] (*:tsk) java.lang.IllegalStateException: a message
[error] Total time: 0 s, completed Feb 15, 2014 11:45:27 PM
I would rather prefer avoiding this style of programming and rely on Option as a way to report an issue with processing.
With the following tskO definition:
lazy val tskO = taskKey[Option[String]]("Task that reports failure as None")
tskO := None
you'd then check the result and if it's None you'd know it's a failure.

MbUnit tests pass when run directly from visual studio, but fails when run via command line

I've been using MbUnit for unit testing for a while, along with Nhibernate and Sqlite.
I am now trying to setup a CI server with Jenkins - I have successfully managed to configure Jenkins to pull the code from github and compile it using MSBuild everytime anyone pushes to github. Finally I want to run tests on the code on each successful build.
The tests all run successfully when run from within Visual Studio without any problem whatsoever, I can run each test individually or the whole project and they all run OK. However when I call Gallio.Echo.exe from command line all the tests that have to do with Sqlite fails.
This is what I've been doing to run the test from command line:
"C:\Program Files\Gallio\bin\Gallio.Echo.exe" /report-type:Html /verbosity:quiet "D:\MyProject\MyProject.Tests\bin\Debug\*.Tests.dll"
(ps: There seems to be absolutely no documentation about gallio tools - have I been looking in all the wrong palces? I want to find more about the command line arguments that I can pass)
The tests fail with this:
Gallio Echo - Version 3.3 build 454
Get the latest version at http://www.gallio.org/
Initializing the runtime and loading plugins.
Verifying test files.
Initializing the test runner.
Running the tests.
[failed] Fixture MyProject.Tests/VerificationTests
Set Up
FluentNHibernate.Cfg.FluentConfigurationException: An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.
---> NHibernate.HibernateException: Could not create the driver from NHibernate.Driver.SQLite20Driver, NHibernate, Version=3.3.1.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4.
---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> System.ArgumentException: Unable to find the requested .Net Framework Data Provider. It may not be installed.
HResult: -2147024809
at System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName)
at NHibernate.Driver.ReflectionBasedDriver..ctor(String providerInvariantName, String driverAssemblyName, String connectionTypeName, String commandTypeName)
at NHibernate.Driver.SQLite20Driver..ctor()
--- End of inner exception stack trace ---
I've tried a few solutions mentioned around on SO but haven't been able to solve it. The only close thing was this answer but I am not sure what the user means by adding to config files.
Anyone has any idea why the tests fail from command line but are okay when run from within VS please?
Thanks.

Resources