Nantes Université

Skip to content
Extraits de code Groupes Projets
Valider 15159a85 rédigé par Theo ARGA's avatar Theo ARGA
Parcourir les fichiers

file assertions tests

parent 834219b7
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!2Implementation of Assertions in commons-assertions module.
......@@ -46,7 +46,7 @@ public class FileAssertion extends ObjectAssertion {
* Asserts that the file does not exist.
*/
public FileAssertion doesNotExist() {
if (!actualValue.exists()) {
if (actualValue.exists()) {
check = false;
message += String.format("\nExpecting file (%s) not to exist but it does", actualValue);
}
......
package org.atlanmod.commons.assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.atlanmod.commons.assertions.Assertion.*;
import static org.junit.jupiter.api.Assertions.*;
import java.io.File;
import static org.atlanmod.commons.assertions.FileAssertion.FileAssertThat;
import static org.junit.jupiter.api.Assertions.assertNotNull;
public class FileAssertionTest {
private File existingtestfile;
private File nonexistenttestfile;
private File directory;
private File hiddenTestfile;
@BeforeEach
public void setup() {
existingtestfile = new File("src/test/resources/testfile.txt");
nonexistenttestfile = new File("src/test/resources/void.txt");
directory = new File("src/test/resources");
hiddenTestfile = new File("src/test/resources/.hiddentestfile.txt");
}
@Test
public void testAssertThat() {
assertNotNull(assertThat(existingtestfile));
}
@Test
public void testExist() {
assertTrue(assertThat(existingtestfile).exists().check());
}
@Test
public void testDoesNotExist() {
assertTrue(assertThat(nonexistenttestfile).doesNotExist().check());
}
@Test
public void testIsReadable() {
assertTrue(assertThat(existingtestfile).isReadable().check());
}
@Test
public void testIsNotReadable() {
assertFalse(assertThat(existingtestfile).isNotReadable().check());
}
@Test
public void testIsWriteable() {
assertTrue(assertThat(existingtestfile).isWriteable().check());
}
@Test
public void testIsNotWriteable() {
assertFalse(assertThat(existingtestfile).isNotWriteable().check());
}
@Test
public void testisDirectory() {
assertTrue(assertThat(directory).isDirectory().check());
}
@Test
public void testIsNotDirectory() {
assertTrue(assertThat(existingtestfile).isNotDirectory().check());
}
@Test
public void testIsHidden() {
assertTrue(assertThat(hiddenTestfile).isHidden().check());
}
@Test
public void testIsNotHidden() {
assertTrue(assertThat(existingtestfile).isNotHidden().check());
}
@Test
public void testIsAbsolute() {
assertFalse(assertThat(existingtestfile).isAbsolute().check());
}
@Test
public void testIsNotAbsolute() {
assertTrue(assertThat(existingtestfile).isNotAbsolute().check());
}
}
\ No newline at end of file
test file, for testing, but hidden.
\ No newline at end of file
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter