Question
JAVA Question Test Driven Development (TDD) is a popular Software Engineering practice where developers write tests first before writing code. For this problem, you will
JAVA Question
Test Driven Development (TDD) is a popular Software Engineering practice where developers write tests first before writing code. For this problem, you will be creating test cases for classes that implement the interface described below:
public interface NumberFormatter
{
String format(int n);
}
Consider three classes that implement this interface. A DecimalSeparatorFormatter formats an integer with decimal separators; for example, one million as 1,000,000. An AccountingFormatter formats negative numbers with parentheses; for example, 1 as (1). A BaseFormatter formats the number in base n, where n is any number between 2 and 36 that is provided in the constructor (i.e, the constructor in the BaseFormatter class takes one integer parameter that specifies the base to be used for conversion). Write a test class called NumberFormatterTests that includes test cases for the above-mentioned three classes. Sample expected output is given below:
DecimalSeparatorFormatter
38756 -> 38,756
956432 -> 956,432
AccountingFormatter
-987654321 -> (987654321)
-287 -> (287)
BaseFormatter
100 -> 100 [Base 10]
21 -> 10101 [Base 2]
1194684 -> 123ABC [Base 16]
Write test cases for valid and invalid input.
You are NOT expected to write the corresponding classes. Your grade will be determined based on the extent to which your test cases pass against the code that the TAs will use for grading. You will not have access to this code.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started