testing why bother
play

Testing Why bother? Professor Larry Heimann Carnegie Mellon - PowerPoint PPT Presentation

Testing Why bother? Professor Larry Heimann Carnegie Mellon University Information Systems Program Why do testing? Comic of the Day... Class example: romanic_testing Get the code at https://github.com/profh/romanic_testing Unit testing


  1. Testing — Why bother? Professor Larry Heimann Carnegie Mellon University Information Systems Program

  2. Why do testing?

  3. Comic of the Day...

  4. Class example: romanic_testing Get the code at https://github.com/profh/romanic_testing

  5. Unit testing assertions • assert(actual, message) # Asserts truth • assert_equal(expected, actual, message) • assert_in_delta(expected_float, actual_float, delta, message) • assert_match(pattern, string, message) • assert_nil(object, message) / assert_not_nil • assert_raise(Exception, ..., message) { block ... } • assert_di ff erence(expressions, di ff erence = 1, &block)

  6. ActiveSupport::TestCase • By default, Rails uses ActiveSupport::TestCase to handle unit testing. • Rails ships with three types of tests: unit (models), functional (controllers), and integration (full MVC stack). • Every method in the test case with a name that starts with test_ represents a single test that gets executed by the framework • Before every test method the setup method is invoked, and afterwards the teardown method • Every test method makes one or more assertions about the behavior of the class under test

  7. More on unit testing • Unit testing is done on models only • All models have a default test created upon rails generate model or rails generate sca ff old • Unit tests are stored in the directory test/models within a Rails project • Tests can be executed using rake test:units or rake test or by executing a particular file (e.g., ruby test/unit/owner_test.rb ) • Can measure test coverage with gems like simple_cov (what we will use in grading phases). These coverage tools are not perfect and especially vulnerable to false positive readings (i.e., says you have full coverage when you do not). No substitute for your own testing analysis.

  8. Looking at basic unit tests in PATS Get the code at https://github.com/profh/PATS_67272

  9. pItlh

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend