Java: binary-search-tree: extract initialization and rename test class

Created on 8 Mar 2017  路  9Comments  路  Source: exercism/java

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().
code good first issue hacktoberfest

All 9 comments

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

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 :)

@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?

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 :)

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

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 :)

@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.

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? :)

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

FridaTveit picture FridaTveit  路  6Comments

FridaTveit picture FridaTveit  路  6Comments

himanshugoyal1065 picture himanshugoyal1065  路  4Comments

rvictorino picture rvictorino  路  5Comments

stkent picture stkent  路  4Comments