Skip to content

binary-search-tree: extract initialization and rename test class #376

Closed

Description

@jtigger

In the binary-search-tree exercise, the test class is named BSTTest and the target class name is BST. For better or for worse, idiomatic Java avoids abbreviations. Also, each test method creates its own instance of BST. Unfortunately, Shalloway's Law applies.

Please:

  1. Rename the test suite to a more descriptive name.
  2. Rename the target class to a congruent name (ideally, the name of the test suite is the name of the class with a Test suffix).
  3. Extract construction of the subject under test in setUp().

Activity

  1. morrme commented on Mar 22, 2017

    @morrme
    Contributor

    I would like to help, with a little guidance if possible.

  2. FridaTveit commented on Mar 22, 2017

    @FridaTveit
    Contributor

    Great, go for it! :) If there's anything you need help with you can just comment on this issue and we can try to help :)

  3. morrme commented on Mar 22, 2017

    @morrme
    Contributor

    @FridaTveit Thank you.
    From what I see, the two files involved are:
    /exercises/binary-search-tree/src/test/java/BSTTest.java
    and
    /exercises/binary-search-tree/src/example/java/BST.java

    Is this correct?

    I am looking at other files to get an idea of a convention for possible test and class names. Do you have a preference or suggestion?

  4. FridaTveit commented on Mar 22, 2017

    @FridaTveit
    Contributor

    Yup, those are the correct files :) The convention for class names in java is to start with a capital letter, use camelCase and avoid abbreviations. So I would suggest BinarySearchTree.java and BinarySearchTreeTest.java :)

  5. delbertlegg commented on Oct 9, 2017

    @delbertlegg
    Contributor

    I'll take this on!
    @FridaTveit I noticed that there is no implementation class yet. Want me to add one with the required stubs?

  6. FridaTveit commented on Oct 9, 2017

    @FridaTveit
    Contributor

    Great! Thanks @delbertlegg! :)

    No, from our POLICIES doc you can see that we only require stubs for the first 20 exercises on the track (i.e. the first 20 exercises listed in config.json). This exercises comes later in the track so there shouldn't be any starter implementation :) I hope that makes sense, let me know if you have any questions :)

  7. delbertlegg commented on Oct 9, 2017

    @delbertlegg
    Contributor

    @FridaTveit Ah, okay...just so I understand completely, there's the test class, and then there's an implemented BST class in the reference folder. What's the purpose of that class? Is the user expected to create a new class in the main/java folder?

    Edit: just fetched the exercise locally and noticed that the reference folder isn't included in the project, so that makes more sense. Assuming that the user will add the class as part of the process.

  8. FridaTveit commented on Oct 9, 2017

    @FridaTveit
    Contributor

    The user will only be provided with the tests, not the reference solution. So yes, they're expected to implement their solution in main/java, where we currently either have a .keep file or a starter implementation, depending on how early in the track the exercise is.

    The reference solution is just for contributors. When you make a PR the travis build will run all the tests against the reference solution (removing all the @Ignore annotations so that all the tests run) and check that they pass. That way we know that the tests are correct in that it's possible to write an example solution which passes all the tests. And it makes it easy to see if any change has broken the tests :) The contributing guide also explains how the exercise modules work. Does that make sense? :)

  9. delbertlegg commented on Oct 9, 2017

    @delbertlegg
    Contributor

    RTFM aye! :) Thanks for the explanation. Working on the fix now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions