Ad
  • Custom User Avatar

    Dear anne123,

    After you "attempted", if you pass all tests, normally the button "Attempt" becomes "Submit" and you have to click on it.

  • Custom User Avatar

    I'd be happy to.

    The text you see there is written as a [comment](https://en.wikipedia.org/wiki/Comment_(computer_programming) so it just informs you and doesn't do anything. In software development there is a methodology named "Agile" which focuses on TDD (test driven development) - it's basically custom written testcases suited to the current project. The "Run Examples" section follows this concept so that the user can write their own custom testcases if they so choose so (it's optional). When creating a Kata the author has the option to either put the "Examples" full of examples testcases, or they can leave it blank and the TDD box will appear for custom written testcases.

    The testing framework on Codewars is custom and so these functions are premade & preloaded already for you. They are used for creating/authoring your own Kata and each function has a different purpose - see here for information.

    • test.expect checks if the actual and expected match through a Boolean value.
    • test.assert_equals checks equality between actual and expected

    blah blah blah look at the link before for more info

    Example

    Test.assert_equals(whatCentury("1999"), "20th", "With input '1999' solution produced wrong output")
    
    It runs the function whatCentury with the parameter "1999" and if the return value is equal to the expected value of "20th" it passes, else error is given.
    

    tl;dr it's for user custom tests

  • Custom User Avatar

    Indeed! Thank you very much for your answer!!!
    What is happening exactly when you launch the tests through "Run Examples" or "Attempt"? I mean behind the button... How these "sections" are organized? The following text is written in the exercise but I don't really get it. Could you explain a bit?

    TODO: Replace examples and use TDD development by writing your own tests

    These are some of the methods available:

    test.expect(boolean, [optional] message)

    test.assert_equals(actual, expected, [optional] message)

    test.assert_not_equals(actual, expected, [optional] message)

    You can use Test.describe and Test.it to write BDD style test groupings

  • Custom User Avatar

    I'm assuming you're clicking the "Run Examples" tab which is just a section for example test cases. Click "Attempt" to go through the actual testcases which allow you to pass and submit your solution.

  • Custom User Avatar

    If I write:

    def whatCentury(year):
    return True (=> with the indentation of course)

    Or even:

    def whatCentury(year):
    print(year) (=> with the indentation of course)

    In Python 3.4 the output is "error" without explanation... Do you know why?

  • Custom User Avatar

    Very clever! I like it :-)
    Bravo!