Strange behavior of unit test in CakePHP Test Suite 2.2 - unit-testing

I am the only one in my development team having this problems with the unit tests.
Either the debugger, nor a google /stackoverflow or my colleagues could help me.
On my machine the unit tests work 10% of the time. The rest of the time they run until they load a site not found page after a long long time.
I have tried everything:
The entire cache is disabled
I tried it out with two browsers
Restarted Apache and MySQL
Login to the app
Debugging with Firebug
Nothing helps.
I have no clue what the problem is.
I'm running windows 8 over bootcamp for work. So there is not much installed (which could lead into side effects).
If I try it out several times, it will work by chance and pass all tests.

The rest of the time they run until they load a site not found page
after a long long time.
Are you executing the tests in the browser? You should use the console over the web front end. Running the tests in the browser can be problematic.

Related

Is there a way to process Karma - Angular unit tests in batches?

We are facing an issue where our tests will start failing or running extremely slow after a certain point. I have seen articles online where others too are facing issues. The primary reason for those failures are memory consumed by browsers while we deal with DOM.
We are using seed project which builds our application using SystemJS. Our Current version of Angular is 2.2.3.
So, I am thinking of a work around where I can either parallel process our test runs (i.e. multiple karma server running, I did try that but it starts to consume 100% CPU) or batch processing. So, batches of small test runs which will ensure that karma is stopped and started again.
Is there a way?
Also, if we are able to achieve that, how to get a consistent coverage? We are using istanbul.
Please let me know if you have any more questions.
e.g. our service and model related tests run in 3 seconds (500+ tests) but our component tests (900+) take 15 mins.
There is pretty good plugin for Karma that allows sharding tests and executing them in parallel - https://www.npmjs.com/package/karma-parallel
We have integrated it in both AngularJS & Angular 4 & 5 projects.
With code-base with more than 2000 tests it is a must.

Web Crawler gets slower with time

I am doing a data extraction project where i am required to build a web scraping program written using python using selenium and phantomjs headless webkit as browser for scaping public information like friendlist in facebook.The program is starting fairly fast but after a day of running it is getting slower and slower and I cannot figure out why ?? Can anyone give me an idea why it is getting slower ? I am running on a local machine which pretty good specs of 4gb ram and quad core processor . Does FB provide any API to find friends of friends ?
We faced the same issue. We resolved this by closing browser automatically after particular time interval. Clear temporary cache and open new browser instance and continue the process.

Improve SOAP UI performance

I've started using SOAP UI recently to test web services and it's pretty cool, but it's a huge resource hog.
Is there any way to reduce the amount of resources it uses?
It shouldn't be a resource hog, although I've seen it do this before. I leave it running on my PC all week, and a co-worker with a similar machine (dual-core running XP) has to kill it every few hours, otherwise it keeps using CPU. I'd try uninstalling/re-installing. Currently, my instance has been up for 10 days, running a mockservice that I've been hitting very hard (I've sent it thousands of requests). CPU time total (over 10 days) is about an hour and a half, but the "right now" number is about 1%.
There are no popular alternatives, aside from writing your own client in the language of your choice.
If you're testing WCF services, you can run wcftestclient from the Visual Studio command line. It works for local or remotely hosted services. Its no good for ASMX-style .NET 2.0 SOAP services though.
if you want to test using only json, you could use some of the light weight Rest clients ex. Mozilla Rest plugin.
We test our SOAP APIs manually with SOAP UI and otherwise use jMeter for automated SOAP API testing. While having a GUI seems attractive first, I find both applications quiet user-unfriendly and time consuming to work with.
As already suggested, you could do it in code using Java or maybe use a dynamic language like Ruby:
Testing SOAP Webservices with RSpec
SOAP web Services testing in RUBY
As user mitchnull mentions in his comment:
Disabling the browser component (-Dsoapui.jxbrowser.disable=true)
solved the 100% CPU usage issues for me. (when it was enabled, it
periodically went to 100% CPU even when not running any
tests/requests).

PHPUnit on a shared hosting plan?

PHPUnit works great, I love it actually, problem I'm having is that my hosting plan imposes a 30 second cap on the duration of a query. If PHPUnit tests take longer than that, the connection is closed by the server, and I never get to find out if all my tests passed or not.
Is there an existing automatic way of running an arbitrarily long test suite using AJAX to batch unit tests so that they'd never hit the 30s threshold? As long as each individual test takes less than 30s I think it should work.
Thanks
Why are you running the tests on the production server? Your tests are for running on your development server, to make sure your code is good before sending into production.
You may be able to change the default timeout with set_time_limit (link). That resets the time left to run whenever it's run.

First call to web service each day is slow

While building this web service and the app that calls it, we have noticed that the first call to the web service each day is extremely slow. It even will time out on some days. However, every call after that work great. Can anybody shed light on why this might be and how we can get rid of this pain?
Thanks in advance!
If it's an ASP.NET web service, it may be the CLR initializing and loading and verifying the assemblies for the first time. You may want to consider pre-compilation
Agree with the other answers on caching, initialization, etc. As far as a workaround, one possibility may be to set up some sort of daily task (SQL Server job, Windows service, something else?) to simulate a hit to the service each day, so that your users don't experience this first slow request.
If it is an ASP.NET web service, then you might want to check the settings of the application pool the web service is running in, especially the idle timeout which defaults to 20 minutes in IIS7.
Configuring IIS7 idle-timeout
Even if it is not an ASP.NET web service, other web servers will have equivalent configuration settings you have to tweak to keep your web service alive overnight.
Can you duplicate the same behavior on your database? It could just be the db needing to optimise the query for the first run (Maybe the parameter is today's date?).
Are there a lot of static constructors or set up code in the Global.asax class? Because IIS recycles worker processes periodically, the start up code may be running again.
The rule for optimization is: don't guess. Put in profiling to find out exactly what is slow, and then work to make that faster. Everything already posted provides excellent tips on where to start looking for slowness.