Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Starting to create more tests #43

Merged
merged 7 commits into from
Feb 15, 2024
Merged

Starting to create more tests #43

merged 7 commits into from
Feb 15, 2024

Conversation

Jean-Baptiste-Camps
Copy link
Member

No description provided.

Copy link

codecov bot commented Feb 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (d8e8c9c) 28.70% compared to head (b005a17) 55.23%.
Report is 1 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master      #43       +/-   ##
===========================================
+ Coverage   28.70%   55.23%   +26.52%     
===========================================
  Files           2        3        +1     
  Lines         108      172       +64     
===========================================
+ Hits           31       95       +64     
  Misses         77       77               
Flag Coverage Δ
unittests 55.23% <100.00%> (+26.52%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@florian-gandon
Copy link

I see you are doing some testing lately.
There is an usual way to format it which is given-when-then: https://martinfowler.com/bliki/GivenWhenThen.html
(my 2 cents)
Florian

@Jean-Baptiste-Camps
Copy link
Member Author

Hi @florian-gandon ! Thanks for the input !
As I understand it, it is a way to document the contents of the test. For instance, if I take one of my existing tests,

# FEATURE: text normalisation before further processing
def test_normalise(self):
    # SCENARIO: I want to normalise a string of text with defaults settings
    # GIVEN the following string
    text = " Hello,  Mr. 𓀁, how are §§ you; doing?"
    # WHEN I apply normalisation
    result = superstyl.preproc.tuyau.normalise(text)
    # THEN I expect the following output in lower case and without punctuation and symbols
    expected_default = "hello mr how are you doing"
    self.assertEqual(result, expected_default)

Or do I miss something ?

@florian-gandon
Copy link

florian-gandon commented Feb 15, 2024

Yes, for instance.
You could also put it in the method name so when failing (or succeed) it is easier to read in the console or in the IDE. Like that:

def givenTextWithUpperCasePunctuationAndSymbols_whenNormalizing_thenTextIsLowerCaseWithoutPunctuation(self):
    # GIVEN
    text = " Hello,  Mr. 𓀁, how are §§ you; doing?"
    # WHEN
    result = superstyl.preproc.tuyau.normalise(text)
    # THEN
    expected_default = "hello mr how are you doing"
    self.assertEqual(result, expected_default)

(or optionally without comments as there is only one line for each part)
The method could be written in a file or a class which describes the feature. I'm not sure what is the usual manner in Python.

@Jean-Baptiste-Camps
Copy link
Member Author

Nice ! I'm not using a lot of class oriented stuff right now, but for the tests, I'm using a class by feature of the main entry points (so a class for data loading, a class for training, etc.), in which I have a test function definition for each function of the source library.

@Jean-Baptiste-Camps
Copy link
Member Author

Merging and closing this one as I need to implement and test a completely new function, but please give feedback whenever you want, it is much appreciated :)

@Jean-Baptiste-Camps Jean-Baptiste-Camps merged commit dbe264b into master Feb 15, 2024
6 checks passed
@Jean-Baptiste-Camps Jean-Baptiste-Camps deleted the moreTests branch February 15, 2024 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants