Package org.fest.assertions.description

Examples of org.fest.assertions.description.Description


    objects.assertEqual(description, actual, expected);
  }

  @Test
  public void should_fail_if_objects_are_not_equal() {
    Description description = new TestDescription("Testing");
    try {
      objects.assertEqual(description, "Luke", "Yoda");
    } catch (AssertionError e) {
      assertEquals("[Testing] expected:<'[Yoda]'> but was:<'[Luke]'>", e.getMessage());
      return;
View Full Code Here


    files.assertIsFile(mock(Description.class), actual);
  }

  @Test
  public void should_fail_if_actual_is_not_file() {
    Description description = new TestDescription("Testing");
    File actual = newDirectory("/usr/local/actual");
    try {
      files.assertIsFile(description, actual);
    } catch (AssertionError e) {
      assertEquals("[Testing] expecting path:</usr/local/actual> to represent an existing file", e.getMessage());
View Full Code Here

    }
  }

  @Test
  public void should_fail_if_files_do_not_have_equal_content() throws IOException {
    Description description = new TestDescription("Testing");
    File actual = newWritableFile("/usr/local/actual.txt");
    File expected = newWritableFile("/usr/local/expected.txt");
    FileDiffs diffs = new FileDiffs();
    diffs.add("line:1, expected:<line1> but was:<%s>");
    diffs.add("line:2, expected:<line2> but was:<EOF>");
View Full Code Here

    strings.assertHasSize(mock(Description.class), null, 3);
  }

  @Test
  public void should_fail_if_size_of_actual_is_not_equal_to_expected_size() {
    Description description = new TestDescription("Testing");
    String actual = "Han";
    int expectedSize = 6;
    try {
      strings.assertHasSize(description, actual, expectedSize);
    } catch (AssertionError e) {
View Full Code Here

  }

  @Test
  public void should_fail_if_Matcher_is_met() {
    matcher.shouldMatch(true);
    Description description = new TestDescription("Testing");
    try {
      matchers.assertIsNot(description, "Yoda", matcher);
    } catch (AssertionError e) {
      assertEquals("[Testing] expecting:<'Yoda'> not to be:<TestMatcher>", e.getMessage());
      verify(failures).failure(same(description), any(ErrorMessageFactory.class));
View Full Code Here

    objects.assertIsInstanceOf(mock(Description.class), null, Object.class);
  }

  @Test
  public void should_fail_if_actual_is_not_instance_of_type() {
    Description description = new TestDescription("Testing");
    try {
      objects.assertIsInstanceOf(description, actual, String.class);
    } catch (AssertionError e) {
      String message = "[Testing] expecting <Person[name='Yoda']> to be an instance of:<java.lang.String> but was "
          + "instance of:<org.fest.assertions.test.Person>";
View Full Code Here

    objects.assertIsInstanceOfAny(mock(Description.class), null, types);
  }

  @Test
  public void should_fail_if_actual_is_not_instance_of_any_type() {
    Description description = new TestDescription("Testing");
    Class<?>[] types = { File.class, String.class };
    try {
      objects.assertIsInstanceOfAny(description, actual, types);
    } catch (AssertionError e) {
      String message = "[Testing] expecting <Person[name='Yoda']> to be an instance of any of:"
View Full Code Here

    strings.assertDoesNotMatch(mock(Description.class), "Yoda", pattern);
  }

  @Test
  public void should_fail_if_actual_matches_Pattern() {
    Description description = new TestDescription("Testing");
    try {
      strings.assertDoesNotMatch(description, "Yoda", Pattern.compile(".*"));
    } catch (AssertionError e) {
      assertEquals("[Testing] expecting:<'Yoda'> not to match regular expression:<'.*'>", e.getMessage());
      verify(failures).failure(same(description), any(ErrorMessageFactory.class));
View Full Code Here

    comparables.failures = failures;
  }

  @Test
  public void should_fail_if_actual_is_not_greater_than_other() {
    Description description = new TestDescription("Testing");
    try {
      comparables.assertGreaterThan(description, actual, other);
    } catch (AssertionError e) {
      String message = "[Testing] expecting:\n<" + quote(actual) + "> should be greater than:<" + quote(other) + ">";
      assertEquals(message, e.getMessage());
View Full Code Here

    strings.assertMatches(mock(Description.class), null, ".*");
  }

  @Test
  public void should_fail_if_actual_does_not_match_regular_expression() {
    Description description = new TestDescription("Testing");
    try {
      strings.assertMatches(description, "Yoda", "Luke");
    } catch (AssertionError e) {
      assertEquals("[Testing] expecting:<'Yoda'> to match regular expression:<'Luke'>", e.getMessage());
      verify(failures).failure(same(description), any(ErrorMessageFactory.class));
View Full Code Here

TOP

Related Classes of org.fest.assertions.description.Description

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.