Studio: Unit Testing
For this studio, you will be writing unit tests to help you find errors in provided code.
Getting Started
Locate the
balanced-brackets
project injava-web-dev-projects/unit-testing/studio
directory.Open the
balanced-brackets
project in IntelliJ.Write unit tests to find the errors in
BalancedBrackets
.- The tests you write should guide how you revise the source code. Use TDD to
first write tests that will work for the desired behavior of
BalancedBrackets
. When your tests fail, correct the class to pass your tests. - The content of your tests is up to you, but you should write at least 12 tests.
TipHere’s a first test to help get you started:
Assert that brackets in the correct order,
"[]"
, return true.@Test public void onlyBracketsReturnsTrue() { assertTrue(BalancedBrackets.hasBalancedBrackets("[]")); }
- The tests you write should guide how you revise the source code. Use TDD to
first write tests that will work for the desired behavior of
BalancedBrackets
is essentially a wrapper class for a method. And
because it’s only method is static, we don’t need to create an instance
to test hasBalancedBrackets()
.
Discuss with your fellow students and IA how the
class should behave. What are some examples of input, and
what would the desired output be for each input?
Uploading Your Work
Push your work to save your solution in your remote repository.