According to Rspec documentation, it is recommended to use the following syntax to write a test script. i.e. the Test script should start with "RSpec.describe":
However This is not mandatory, you can also write Rspec script without creating a dummy class. Just write your script by using "describe" instead of "RSpec.describe" as below
#example_spec.rb
#
RSpec.describe EvampleTest do describe '#Group 1' do it 'test 1', :smoke => true do end
end
When you run the above example, it throws error uninitialized constant EampleTest (NameError), this happens because the class 'ExampleTest' is not defined. You have create a file with class 'ExampleTest' in lib folder like this#lib/example.rb
class ExmpleTest end
And include 'exmple.rb' in your script
#example_spec.rb
use 'example'
RSpec.describe EvampleTest do describe '#Group 1' do it 'test 1', :smoke => true do end
end
However This is not mandatory, you can also write Rspec script without creating a dummy class. Just write your script by using "describe" instead of "RSpec.describe" as below
#example_spec.rb
#
describe "Example Test" do describe '#Group 1' do it 'test 1', :smoke => true do end
end
No comments:
Post a Comment