Given the obvious implementation (without any validation of parameters) of the C
ID: 3674574 • Letter: G
Question
Given the obvious implementation (without any validation of parameters) of the Coin class m the following UML diagram: Write a suite of JUnit tests that covers every method, statement, and branch in the Coin class. Given the information you have available to you, why could you not write such a JUnit test suite for the Metal class, even though it only has one method? Create a UML class diagram for a Combination class based on the following textual description. A combination lock is either "locked" or "unlocked". A combination lock has an associated combination (i.e., a sequence of 1 or more characters) that cannot be changed. A user can enter a combination: if the combination is correct then the combination lock becomes "unlocked". A user can also "lock" a combination lock.Explanation / Answer
import org.junit.Test;
import org.junit.Ignore;
import static org.junit.Assert.assertEquals;
public class TestJunit1 {
String metal=”silver”;
double weight=20;
Coin c = new Coin(weight,metal);
@Test
public void getMetal() {
System.out.println("Inside getMetal()");
assertEquals(metal, c.getMetal());
}
}
JUnit automatically catches exceptions. It considers uncaught exceptions to be errors, which means the given class Metal has redundant code in it.so, could not write Junit Test suit for it..
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.