Balaji Vajjala's Blog

A DevOps Blog from Trenches

03.01

  • 3.1 Write scripted unit tests
    • Learning Objectives
    • EXERCISE: View and run unit tests
    • EXERCISE: View and run unit tests (OPTIONAL)

3.1 Write scripted unit tests

Learning Objectives

By the end of this lesson you will be able to:

  • View and run unit tests.

EXERCISE: View and run unit tests

  1. From the AWSCLI instance, go to the unit test directory of the continuous_integration_example project.
  2. Open the BeerServiceUnitTest.java file

    “` $ sudo vim BeerServiceUnitTest.java

    “`

EXERCISE: View and run unit tests (OPTIONAL)

  1. If you haven’t done so already, run the TargetEnvironment job on your Jenkins instance.
  2. SSH into this target environment instance. Your Public DNS will be different

    “` $ ssh -i cd.pem ec2-user@IPADDRESS

    “`

  3. Go to the Rails deployment directory.

    “` $ cd /var/www/rails

    “`

  4. Apply database tables

    “` $ sudo rake db:migrate

    “`

  5. Prepare the tests using Rake

    “` $ sudo rake test:prepare

    “`

  6. Run Bundler. Files to download are specified in Gemfile

    “` $ sudo bundle install

    “`

  7. Run the RSpec tests

    “` $ sudo rspec spec/

    “`