We'll be
Open IntelliJ Choose "New Project" Select "Maven Project"
Set your "groupId" com.yourname.tdd.intro
Set your "artifactId" to intro
Name the project folder "tdd-first-steps"
Create a new file .gitignore in your tdd-first-steps folder
# OS files to ignore
.DS_Store
Thumbs.db
# Editor files to ignore
*.iml
.idea/*
# ignore compiled .class files
out/
Open your terminal
git init
git status
git add .gitignore
git status should show .gitignore as green, which means it's ready to be committed
git commit -m "Add files to ignore to .gitignore" will make a commit containing the gitignore file
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
linkedlist doublylinkedlist queue Stack isEmpty push peek pop contains size peekNth
Inside of tdd-intro/src/test/, create a new Java class named TruthTest.java
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class TruthTest {
@Test
public void baseTruth() {
assertEquals(true, true);
}
}
- Run your tests.
- To run your tests
- The mac keyboard shortcut is control then shift then R.
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
public class TruthTest {
@Test
public void baseTruth() {
assertEquals(true, true);
assertNotEquals(true, false);
}
}
- Run your tests
- Take stock that we now have an automated
import org.junit.Test;
public class StackTest {
@Test
public void testIsEmpty() {
Stack stack = new Stack();
}
}
public class Stack {
}
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class StackTest {
@Test
public void testIsEmpty() {
Stack stack = new Stack();
assertEquals(true, stack.isEmpty());
}
}
public class Stack {
public boolean isEmpty() {
return true;
}
}
- It's OK that this implementation isn't perfect. The goal is to green the test.
- Run all tests
Now it's time to implement a .push method