@@ -27,20 +27,20 @@ cw-2:
2727 # NOTE: You can use Test or test, whichever you prefer.
2828
2929 # Use "describe" to label your test suite.
30- Test.describe("two_oldest_ages: ")
31-
32- # Use "it" to identify the conditions you are testing for
33- Test.it("should return the second oldest age first")
34- # using assert_equals will report the invalid values to the user
35- Test. assert_equals(results1[0], 45)
36- # using expect will just give a user a generic error message, unless you provide a message
37- Test. expect(results2[0] == 18, "Number is not the second oldest")
38-
39- # its best practice to test for multiple groups of tests, using it calls.
40- Test.it("should return the oldest age last")
41-
42- Test.assert_equals(results1[1], 87)
43- Test.expect(results2[1] == 83, "Number is not the oldest")
30+ @ Test.describe("Two Oldest Ages ")
31+ def describe1():
32+ # Use "it" to identify the conditions you are testing for
33+ @ Test.it("should return the second oldest age first")
34+ def it1():
35+ # using assert_equals will report the invalid values to the user
36+ Test.assert_equals(results1[0], 45)
37+ # using expect will just give a user a generic error message, unless you provide a message
38+ Test.expect(results2[0] == 18, "Number is not the second oldest")
39+ # its best practice to test for multiple groups of tests, using it calls.
40+ @ Test.it("should return the oldest age last")
41+ def it2():
42+ Test.assert_equals(results1[1], 87)
43+ Test.expect(results2[1] == 83, "Number is not the oldest")
4444
4545 bug fixes :
4646 initial : |-
@@ -53,21 +53,20 @@ cw-2:
5353
5454 fixture : |-
5555 # Use "describe" to define the test suite
56- test.describe('add method')
57-
58- # Use "it" to indicate a condition you are testing for
59- test.it('should add both arguments and return')
60-
61- # "assert_equals" will return information about what values were
62- # expect if the assertion fails. This can be very useful to other
63- # users trying to pass the kata.
64- test.assert_equals(add(1,2), 3)
65-
66- # "expect" is a lower level assertion that will allow you to test
67- # anything. It just needs a boolean result. You should pass a message
68- # as the second parameter so that if the assertion fails the user
69- # will be giving some useful information.
70- test.expect(add(1,1) == 2, "add(1,1) should == 2")
56+ @test.describe('add method')
57+ def describe1():
58+ # Use "it" to indicate a condition you are testing for
59+ @test.it('should add both arguments and return')
60+ def it1():
61+ # "assert_equals" will return information about what values were
62+ # expect if the assertion fails. This can be very useful to other
63+ # users trying to pass the kata.
64+ test.assert_equals(add(1,2), 3)
65+ # "expect" is a lower level assertion that will allow you to test
66+ # anything. It just needs a boolean result. You should pass a message
67+ # as the second parameter so that if the assertion fails the user
68+ # will be giving some useful information.
69+ test.expect(add(1,1) == 2, "add(1,1) should == 2")
7170
7271 refactoring :
7372 initial : |-
@@ -85,30 +84,29 @@ cw-2:
8584
8685 fixture : |-
8786 # Use "describe" to define the test suite
88- test.describe('Person')
89-
90- jack = Person('Jack')
91-
92- # Use "it" to indicate a condition you are testing for
93- test.it('should have a name')
94-
95- # "assert_equals" will return information about what values were
96- # expect if the assertion fails. This can be very useful to other
97- # users trying to pass the kata.
98- test.assert_equals(jack.name, "Jack")
99-
100-
101- test.it("should greet Jill")
102-
103- test.assert_equals(jack.greet("Jill"), "Hello Jill, my name is Jack")
104-
105- test.it("should greet other people as well")
106-
107- # unlike "assert_equals", "expect" is a lower level assertion that
108- # takes a boolean to determine if it passes. If it fails it will
109- # output the message that you give it, or a generic one. It is a good
110- # idea to provide a custom error message to help users pass the kata
111- test.expect(jack.greet("Jane") == "Hello Jane, my name is Jack", "Jack apparently is only able to greet Jane")
87+ @test.describe('Person')
88+ def describe1():
89+ jack = Person('Jack')
90+
91+ # Use "it" to indicate a condition you are testing for
92+ @test.it('should have a name')
93+ def it1():
94+ # "assert_equals" will return information about what values were
95+ # expect if the assertion fails. This can be very useful to other
96+ # users trying to pass the kata.
97+ test.assert_equals(jack.name, "Jack")
98+
99+ @test.it("should greet Jill")
100+ def it2():
101+ test.assert_equals(jack.greet("Jill"), "Hello Jill, my name is Jack")
102+
103+ @test.it("should greet other people as well")
104+ def it3():
105+ # unlike "assert_equals", "expect" is a lower level assertion that
106+ # takes a boolean to determine if it passes. If it fails it will
107+ # output the message that you give it, or a generic one. It is a good
108+ # idea to provide a custom error message to help users pass the kata
109+ test.expect(jack.greet("Jane") == "Hello Jane, my name is Jack", "Jack apparently is only able to greet Jane")
112110
113111 reference :
114112 initial : |-
@@ -119,17 +117,16 @@ cw-2:
119117
120118 fixture : |-
121119 # Use test.describe (or Test.describe) to describe your test suite
122- test.describe("websites")
123-
124- # Use "it" calls to describe the specific test case
125- test.it("should have the value 'codewars' inside of it")
126-
127- # assert equals will pass if both items equal each other (using ==). If
128- # the test fails, assert_equals will output a descriptive message indicating
129- # what the values were expected to be.
130- test.assert_equals(['codewars'], websites)
131-
132- # you can also use the lower level test.expect. If you use test.expect directly then
133- # you should provide a custom error message, as the default one will be pretty useless
134- # to users trying to pass the kata.
135- test.expect(['codewars'] == websites, 'Array does not have correct value')
120+ @test.describe("websites")
121+ def describe1():
122+ # Use "it" calls to describe the specific test case
123+ @test.it("should have the value 'codewars' inside of it")
124+ def it1():
125+ # assert equals will pass if both items equal each other (using ==). If
126+ # the test fails, assert_equals will output a descriptive message indicating
127+ # what the values were expected to be.
128+ test.assert_equals(['codewars'], websites)
129+ # you can also use the lower level test.expect. If you use test.expect directly then
130+ # you should provide a custom error message, as the default one will be pretty useless
131+ # to users trying to pass the kata.
132+ test.expect(['codewars'] == websites, 'Array does not have correct value')
0 commit comments