You can download this code by clicking the button below.
This code is now available for download.
This code defines a Behave step definition to test a function that generates a random word of a specified length.
Technology Stack : Behave, string, random
Code Type : Behave Step Definition
Code Difficulty : Intermediate
from behave import Given, When, Then
def generate_random_word(length):
import random
import string
letters = string.ascii_letters
return ''.join(random.choice(letters) for i in range(length))
Given('a random word generator with length {length}')
When('I call the generator')
Then('I should get a random word of length {length}')