Difference between revisions of "Lapis Lazuli:Usage"

From Test Automation Wiki
Jump to: navigation, search
Line 16: Line 16:
 
However, you don't need to drink from the firehose, and can instead pick and choose which extensions to use:
 
However, you don't need to drink from the firehose, and can instead pick and choose which extensions to use:
  
<pre>
+
<syntaxhighlight lang="Ruby" line="1">
 
# features/support/env.rb
 
# features/support/env.rb
 
require 'lapis_lazuli/world/annotate'
 
require 'lapis_lazuli/world/annotate'
 
World(LapisLazuli::WorldModule::Annotate)
 
World(LapisLazuli::WorldModule::Annotate)
</pre>
+
</syntaxhighlight>
  
 
There's one caveat: the most useful `WorldModule` is the `Browser` module, which handles creating and destroying an enhanced watir browser instance for you. To do so, this module includes quite a few other <code>WorldModules</code>. In fact, it's not the only module that does so. In many cases, then, simply including all of LapisLazuli is going to be the easiest.
 
There's one caveat: the most useful `WorldModule` is the `Browser` module, which handles creating and destroying an enhanced watir browser instance for you. To do so, this module includes quite a few other <code>WorldModules</code>. In fact, it's not the only module that does so. In many cases, then, simply including all of LapisLazuli is going to be the easiest.
Line 29: Line 29:
 
In order to get the full power of LapisLazuli, you will most likely want to automatically add the hooks from the [[WorldModule:Hooks]] module. You can do this by also requiring the <code>cucumber</code> file:
 
In order to get the full power of LapisLazuli, you will most likely want to automatically add the hooks from the [[WorldModule:Hooks]] module. You can do this by also requiring the <code>cucumber</code> file:
  
<pre>
+
<syntaxhighlight lang="Ruby" line="1">
 
# features/support/env.rb
 
# features/support/env.rb
 
require 'lapis_lazuli'
 
require 'lapis_lazuli'
 
require 'lapis_lazuli/cucumber'
 
require 'lapis_lazuli/cucumber'
 
World(LapisLazuli)
 
World(LapisLazuli)
</pre>
+
</syntaxhighlight>
  
 
== Interactive Usage ==
 
== Interactive Usage ==
Line 40: Line 40:
 
Interactive usage of LapisLazuli in <code>irb</code> is just as easily possible:
 
Interactive usage of LapisLazuli in <code>irb</code> is just as easily possible:
  
<pre>
+
<source>
 
$ irb
 
$ irb
 
irb(main):001:0> require 'lapis_lazuli'
 
irb(main):001:0> require 'lapis_lazuli'
Line 48: Line 48:
 
irb(main):003:0> browser.goto "http://www.spritecloud.com"
 
irb(main):003:0> browser.goto "http://www.spritecloud.com"
 
=> "http://www.spritecloud.com/"
 
=> "http://www.spritecloud.com/"
</pre>
+
</source>
  
 
== New Projects ==
 
== New Projects ==
Line 54: Line 54:
 
In many cases you will be starting out with a new test automation suite. LapisLazuli helps you with that, by creating one from a template included in the library:
 
In many cases you will be starting out with a new test automation suite. LapisLazuli helps you with that, by creating one from a template included in the library:
  
<pre>
+
<source>
 
$ lapis_lazuli create <projectpath>
 
$ lapis_lazuli create <projectpath>
</pre>
+
</source>
  
 
A skeleton test suite with LapisLazuli loaded will be created at the given project path. You can use <code>create</code> - or it's alias <code>update</code> - to keep the test suite up-to-date when you upgrade to a new version of LapisLazuli, too.
 
A skeleton test suite with LapisLazuli loaded will be created at the given project path. You can use <code>create</code> - or it's alias <code>update</code> - to keep the test suite up-to-date when you upgrade to a new version of LapisLazuli, too.

Revision as of 08:49, 28 June 2016

LapisLazuli provides extra functionality for your cucumber test suites. The library is structured in the following way:

  1. It provides extensions to the cucumber World object - the object that provides all the methods you can use in your step definitions. These extensions are implemented in WorldModule modules.
  2. It provides an enhanced version of the watir browser. Extensions to the browser are implemented in BrowserModule modules.

Usage

The LapisLazuli module itself includes all WorldModule functionality provided by the library. To use all the extensions at once, simply do the following:

# features/support/env.rb
require 'lapis_lazuli'
World(LapisLazuli)

However, you don't need to drink from the firehose, and can instead pick and choose which extensions to use:

# features/support/env.rb
require 'lapis_lazuli/world/annotate'
World(LapisLazuli::WorldModule::Annotate)

There's one caveat: the most useful `WorldModule` is the `Browser` module, which handles creating and destroying an enhanced watir browser instance for you. To do so, this module includes quite a few other WorldModules. In fact, it's not the only module that does so. In many cases, then, simply including all of LapisLazuli is going to be the easiest.

Lapis Lazuli library consist of a module called LapisLazuli and its main class LapisLazuli. The class is a singleton, which means that any reference to LL will be the same instance with links to the same browser window.

In order to get the full power of LapisLazuli, you will most likely want to automatically add the hooks from the WorldModule:Hooks module. You can do this by also requiring the cucumber file:

# features/support/env.rb
require 'lapis_lazuli'
require 'lapis_lazuli/cucumber'
World(LapisLazuli)

Interactive Usage

Interactive usage of LapisLazuli in irb is just as easily possible:

$ irb
irb(main):001:0> require 'lapis_lazuli'
=> true
irb(main):002:0> include LapisLazuli
=> Object
irb(main):003:0> browser.goto "http://www.spritecloud.com"
=> "http://www.spritecloud.com/"

New Projects

In many cases you will be starting out with a new test automation suite. LapisLazuli helps you with that, by creating one from a template included in the library:

$ lapis_lazuli create <projectpath>

A skeleton test suite with LapisLazuli loaded will be created at the given project path. You can use create - or it's alias update - to keep the test suite up-to-date when you upgrade to a new version of LapisLazuli, too.

Documentation Structure

Because of the structure of the library, the wiki documentation is structured by WorldModule and BrowserModule, too.