Consistent Testing
electron-settings

TL;DR: Delete the settings file before starting the test. Today I implemented a simple wrapper over the electron-settings functionality to gibe me access to a set of properties via get/set methods. My scenario is simple: I have a property named path.backup and I want to be able to get, set andtest it’s set`. The code […]

Poor Man’s Mocks in TypeScript

Today I went against my better judgement of usign a mock framework and decided to create my own mocks to allow coverage testing for an IPC-calling code. My reference code I wanted to test is:

The code would use an angular service named PathService which, for the purpose of this test only has a […]

Use “toThrowError” and “toThrow” in TypeScript with Objects

TL;DR: wrap your method call in the expect() statement. Instead of expect(obj.method()).toThrow(), write expect( () => { obj.method() }).toThrow(). While in the process of improving the code coverage, I needed to write a test for a method throwing an exception. My initial code would have been something like:

Where SelectorComponent has a method named […]

Fix Angular 2 Tests with Karma

Below are some fixes I had to apply in order to make Angular 2 tests work with karma. Binding Error: Can’t bind to ‘ngModel’ since it isn’t a known property of ‘input’ Solution: Import FormsModulein your test:

Unknown component Error: ‘custom-component’ is not a known element Solution: Declare the component in your test:

[…]

Skip the EPSO Online Test

TL;DR:: Replace the end of the application URL from e.g. 1947_en to 1947/apply_en. These days, EPSO is in the habit of launching calls with multiple fields with a twist: each field has its own application page. So, if you just want to browse the fields for more details (e.g. Talent Screener in specialist competitions), you’d […]

Access Data Files for Local Tests in Android

TL;DR: Put your data files in test/resources and access it with:

I’ve got an android application with a module performing data processing (HTML scraping in fact). This part is pure java and all its tests are in the src/test path. My particular problem is that I have a set of (large-ish) files to be […]

MVP in Android – A Summary

These days I’m reading on architectures. I had a look at MVC, MVP, MVVM and how they are applied (adapted to?) to Android applications. Here are some short points about MVP. Model-View-Presenter has been adapted to Android and is advocated by more experienced people than I. It is interesting to note that in the Clean […]

Android: Provide Local Asset in Testing

In the past few days I had a little bit of a problem: InstrumentationTestCase gives access to local assets while AndroidTestCase gives access to getAssets() for assets specific to testing. I had a scenario to test where I get a file from my local src/androidTest/assets directory while the code would need to write some files […]

NullPointerException – getInstrumentation().getContext()

Here’s a beginner mistake… The following code:

Throws an exception: Attempt to invoke virtual method ‘android.content.Context android.app.Instrumentation.getContext()’ on a null object reference It took me some time to find out why: getInstrumentation() returns null in the constructor :) The correct way is to use setUp():

Then, you can call super in classes extending […]

Scroll to top