Skip to content

Instantly share code, notes, and snippets.

@bcalmac
Created March 15, 2015 16:42
Show Gist options
  • Save bcalmac/16de6b918222aa9ed5db to your computer and use it in GitHub Desktop.
Save bcalmac/16de6b918222aa9ed5db to your computer and use it in GitHub Desktop.
Asserting file content with AssertJ
import java.io.File;
import org.junit.Test;
import static org.assertj.core.api.Assertions.*;
public class FileTest {
@Test
public void file() {
File actualFile = new File("actual.txt");
File expectedFile = new File("expected.txt");
assertThat(actualFile).hasContentEqualTo(expectedFile);
}
@Test
public void inline() {
File actualFile = new File("actual.txt");
assertThat(linesOf(actualFile)).containsExactly(
"line 1",
"line 2",
"line 3"
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment