Writing unit tests for Sugar 7

Document created by ygadeau Employee on May 2, 2016Last modified by Matt Marum on Jun 22, 2016
Version 4Show Document
  • View in full screen mode



Learn how to write unit tests for Sugar 7 both back-end and front-end components. Get an overview of our test frameworks including practical examples.


Attendees of this session will come away with...

  • An understanding of the unit test suites in Sugar 7.
  • The ability to write and run unit tests for your own components.



1. Jasmine unit tests (FRONT-END)

  • Tooling: Jasmine, Sinon.js, karma.js
  • How to test a sugar component ? What to test? For what purpose?
  • Writing a simple test. (practical examples)
  • Spying/stubbing functions with sinon.js
  • Example of more complex unit tests using stubs/spies and a fake server.
  • Gulp tasks.


2. PhpUnit unit tests (BACK-END)

  • Tooling: PHPUnit
  • Writing a simple PHPUnit test for Sugar
  • Mocking objects for testing
  • Using data providers for testing multiple test cases with one harness
  • Writing more complex PHPUnit tests
  • Discuss setup(), tearDown(), setupBeforeClass() and tearDownAfterClass()
  • Discuss test suites, the full suite, and isolated tests



  • Presenter: Yvan Gadeau & Robert Gonzalez
  • Duration: 1 hour
  • Target Audience: Sugar Development Beginners to Advanced
  • Prerequisites: Laptop
2 people found this helpful