HyperDrive: Update #9

Intended Audience: Marija Bezbradica (FYP Supervisor)

Made progress with:

  • Writing integration tests for API.
  • Writing unit tests for front end.
  • Implementing E2E testing with protractor.

I left the implementation of most of the testing for the project towards the end so I favoured implementing a number of different types of testing rather than being concerned with a high level of code coverage.

Early in the development process I set up a continuous deployment pipeline to build, test and deploy the project to my development server, after each github commit. I made use of github’s webhooks to trigger a Jenkins job. There was a number of steps involved in the process, Jenkins would:

  • Wipeout the local instance of the project
  • Clone the codebase from github
  • Download all dependencies
  • Run all tests (if successful):
  • Build the project .jar file
  • Connect to development server over ssh
  • Check if an instance of the project was running and stop it.
  • Copy .jar to the server
  • Execute the start script to run the project.

My testing of the API consisted of unit tests for a number of components as well as integration tests for the API endpoints.

I wrote a number of jUnit tests for the Security Utils class. This class is responsible for getting the current user, establishing if they are authenticated as well as checking what roles they are associated with. Each method in this class had a corresponding unit test to establish that they were behaving as expected.
Each of the rest endpoints was given a corresponding test class. These tests differ from the unit tests above because they require a full instance of the application to be running in order for them to execute.

I used the Spring Test Context framework to test almost all of the API methods. The basic workflow of these tests would be to assess the state of a repository, use the MockMVC class to simulate an API call and then assess if the API response was as expect and if the repository had been modified accordingly.

Marking these tests with the @Transactional annotation informed the system to revert the transaction after the test had been completed.
Unit testing for the web application was written in Jasmine and run with KarmaJS. They mock up access to the REST endpoints to enable testing of the UI components.
I used Protractor to automate tests for the front end. Protractor is an end to end testing framework for AngularJs built on top of Selenium Web Driver.

When run it opens a firefox window and simulates click through behaviour. It then evaluates the system behaviour against its expected behaviour.

Leave a Reply

Your email address will not be published. Required fields are marked *