Creating your first ta project
Contents
Creating the project folder
The easiest way to do this is using Lapis_Lazuli's build in create
function. This will create all needed folders and files to get started. If you like, you could also do this manually.
- Open CMD
- Go to the folder where you want to create you project
- For example:
cd C:/ruby/projects/
- For example:
- Write
lapis_lazuli create <projectname>
- Where <projectname> is the name of your project without `<>`
Running the project for the first time
The project created by Lazis Lazuli has some basic scripts. To confirm it's working properly, let's run it!
Continue from where we left off in the CMD:
- First we are going to install another gem
gem install bundler
- Once it's installed write
bundle install
this will automatically download all the required gems that you need for this project. - To run the project you need to be in the project folder
cd <projectname>
- To execute the project write
bundle exec cucumber
You should see a browser pop-up after a few seconds that automatically clicks through some pages. Once it's finished you should see something like this in CMD:
1 scenario (1 passed) 3 steps (3 passed) 0m10.054s
Open project
After creating your project, you will have a folder structure similar as below. Feel free to click around the folders and open the files. There are many text editors (free and paid) you could use to open the files. Windows machines uses by default a program called "Notepad". However, there are programs like Atom that will improve the usability by making it easy to navigate between files and make the code more readable. If you don't want to use such a program we recommend that you use at least download Notepad++
01.─┬/config/ 02. ├─> config.yml 03. └─> cucumber.yml 04.─┬/features/ 05. ├─┬/step_definitions/ 06. │ ├─> interaction_steps.rb 07. │ └─> validation_steps.rb 08. ├─┬/support/ 09. │ ├─> env.rb 10. | └─> functions.rb 11. ├─> example.feature 12. └─> mobile.feature 13.──/log/ 14.──/results/ 15.──/sceenshots/
Extra information
About Bundle gem
The purpose of using the Bundle gem is to make life easier. Bundle will help us to automatically install all required gems. And on top of that it's smart enough to know the dependencies between gems.
Without Bundle you execute Cucumber by just writing cucumber
.
But this will result in many errors that would say we needed to download multiple gems like, Cucumber, Selenium-webdriver and watir-webdriver.
Detailed information about every folder
- 01. /config/
- This folder contains configuration information about your project. Some handy things you can do here is write credentials that will later be re-used throughout your whole automation project.
- 04. /features/
- This is the core of your project. It contains the test cases, the code executed in the steps of your test cases and any other code you wish to write for your solution.
- 05. step_definitions
- This folder contains the definitions of the steps you've described in your feature files. Any file ending with "_steps.rb" will be included in the execution. So you can create the files however you feel it will be most organized.
- 11. example.feature
- This file contains your test cases, split up in Features which contain Scenario's which Contains Steps.
- More information about writing Feature files can be found in Writing_gherkin_test_cases_in_cucumber
- 08. /support/
- This folder contains files that supports writing steps or the execution.
- Env.rb does things like setting up a profile before a browser is opened.
- Functions.rb can be used to place methods you're using often.
- 13. /log/
- This will contain logging information after each test you have executed
- 14. /results/
- Can be used to export results of you test run to
- 15. /screenshots/
- Any screenshot taken by your scripts will be stored in this folder.
Information about setting up your text editor
If you choose not to use a simple text editor like "Notepad", you sometimes need to setup the software to recognize the programming language we're using in this tutorial. Inside the text editor we need to download various plugins (also called add-ons or something similar) if they're not ready installed. In this tutorial we make use of "Ruby", "Cucumber", "Selenium" and "Gherkin". When these plugins are installed the text editor recognizes the code and if you make by mistake a typo the editor shows it. Some editors also help you write code by showing you the options you can choose from and extra information about the functions or methods you're using.