Regression testing
Regression testing is a type of testing that involves testing the software application after a change or modification has been made to ensure that existing functionality has not been affected. Here is an example of a regression test written in Ruby using the RSpec library:
perl
require 'calculator'
describe Calculator do
describe '#add' do
it 'returns the sum of two numbers' do
calculator = Calculator.new
expect(calculator.add(2, 3)).to eq(5)
end
it 'returns the sum of two negative numbers' do
calculator = Calculator.new
expect(calculator.add(-2, -3)).to eq(-5)
end
end
end
In this example, we define a class Calculator that contains a method add that performs addition operations. We also define a regression test that tests the add method of the Calculator class after a change has been made. The test ensures that the add method still returns the correct output after the change.
No comments:
Post a Comment