Monday, March 30, 2020

Cheat-Sheet for running a simple Feature Test using Behave with Pycharm (Community edition)

        1. Install Python 3.8 
        2. Install Pycharm Community Edition 
        3. Install Gherkin(pip install gherkin-official)
     a.     Open Pycharm
     b.     Press Ctrl+Alt+S , select Plugins.
     c.      It will look like this 
 
     d.     Select marketplace (top middle) 
     e.     In the search on the top (Type/ to see options) type ‘Gherkin’


 
    f.     Click install and Gherkin will be installed.   
4.  Install behave (pip install -U behave in the command prompt) 
5.Open Pycharm and create a new project (Testing)  
6.Under the project create directory and name it as ‘features’
          7.     Under features create a new file and name it as ‘tutorial.feature’
          8.     To run a very simple program copy the following in ‘tutorial.feature’

               Feature: showing off behave

                 
Scenario: run a simple test
                    
Given we have behave installed
                    
When we implement a test
                    
Then behave will test it for us!
              
           9.    Create another directory called ‘steps’ under‘features’
                10.     Under ‘steps’ create a python file and name it as ‘tutorial.py’
                11.    The flow would be like this



 
                12.   Type the following in ‘tutorial.py’
 
from behave import *
@given('we have behave installed')def step_impl(context):
    pass

@when('we implement a test')def step_impl(context):
   assert True is not False

@then('behave will test it for us!')def step_impl(context):
    assert context.failed is False

                 13.   To run behave
a.     Install behave in the virtual environment ie. in the terminal type ‘pip install behave’


b.     Check if behave is installed. 
 

             14.     Run each python file with .py extension individually and check for errors. This can be done by opening the file, right-click and select Run 'file-name'.

             15.  To run the project click ‘Run’ in the menu on the top of the screen.
                  16.      You will get a pop up which says Edit Configuration

             17.    Click on it and the following screen will appear



        18.   Click on Python to see the__main__ file and edit the configuration
        19  The first entry Name should be __main__
        20.    Script path is (path of  __main__ file.py ) C:\Users\SASHA\AppData\Local\Programs\Python\Python38\Lib\site-packages\behave\__main__.py
        21.    Working directory is the path of the project ‘Testing’
         C:\Users\SASHA\PycharmProjects\Testing
        22.    Checkmark the Emulate terminal in the output console to see the output in the terminal.
        23.   Click ‘Apply’ and ‘Run’
        24.   The following output will be seen in the terminal


               CONGRATULATIONS !! YOU WON !!

The Winning Combo – Cryptocurrency and Block Chain

  The Winning Combo – Cryptocurrency and Block Chain ABSTRACT: Commercial transactions on the Internet have come to rely exclusively on ...