public class DependencyTracker { String theDependency = ""; public String getDependencies(String dependencyName) { return theDependency; } // If "a" depends on "b," "a" is `dependent` and "b" is dependendUpon public void registerDependency(String dependent, String dependedUpon) { theDependency = "H"; } }
- public class DependencyTracker {
- String theDependency = "";
- public String getDependencies(String dependencyName) {
return "";- return theDependency;
- }
- // If "a" depends on "b," "a" is `dependent` and "b" is dependendUpon
- public void registerDependency(String dependent, String dependedUpon) {
- theDependency = "H";
- }
- }
import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; // TODO: Replace examples and use TDD by writing your own tests class DependencyTrackerTest { @Test void noDependencies() { DependencyTracker tracker = new DependencyTracker(); String dependencies = tracker.getDependencies("H"); assertEquals("", dependencies); } @Test void oneDependency() { DependencyTracker tracker = new DependencyTracker(); tracker.registerDependency("G","H"); String dependencies = tracker.getDependencies("G"); assertEquals("H", dependencies); } }
- import org.junit.jupiter.api.Test;
- import static org.junit.jupiter.api.Assertions.assertEquals;
- // TODO: Replace examples and use TDD by writing your own tests
- class DependencyTrackerTest {
- @Test
- void noDependencies() {
- DependencyTracker tracker = new DependencyTracker();
- String dependencies = tracker.getDependencies("H");
- assertEquals("", dependencies);
- }
- @Test
- void oneDependency() {
- DependencyTracker tracker = new DependencyTracker();
- tracker.registerDependency("G","H");
- String dependencies = tracker.getDependencies("G");
- assertEquals("H", dependencies);
- }
- }