All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.eclipse.epsilon.eol.exceptions.EolAssertionException Maven / Gradle / Ivy

The newest version!
/*******************************************************************************
 * Copyright (c) 2008-2011 The University of York.
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which is available at https://www.eclipse.org/legal/epl-2.0/
 * 
 * Contributors:
 *     Dimitrios Kolovos - initial API and implementation
 *     Antonio Garcia-Dominguez - actual/expected/delta fields
 ******************************************************************************/
package org.eclipse.epsilon.eol.exceptions;

import org.eclipse.epsilon.common.module.ModuleElement;

/**
 * Exception which is thrown when the expectations in a test case are not met.
 * These exceptions include information about the expected value and the value
 * which was obtained, if available. Optionally, a custom object representing
 * the difference between the expected and actual value can be stored.
 */
public class EolAssertionException extends EolRuntimeException {

	private static final long serialVersionUID = 1L;
	private final Object expected, actual, delta;

	/**
	 * 

* Creates a new instance. There are three acceptable combinations for the * values of expected, actual and * delta: *

* *
    *
  1. None are null: expected and actual values are available, * and their difference has been precomputed.
  2. *
  3. delta is null: expected and actual values * are available, but the difference has not been precomputed. A regular * text-based line-by-line comparison will be used.
  4. *
  5. All three are null: no information is available. This * may happen when calling the fail(msg) built-in operation, * for instance, or when using assertNotEquals (it may not make sense to * present differences when they are really the same).
  6. *
* * @param reason * String explaining the expectation which was not met. * @param ast * AST node of the call to the assertion operation whose test * failed. * @param expected * Expected value, if applicable. Otherwise, null. * @param actual * Actual value, if applicable. Otherwise, null. * @param delta * Precomputed delta between the values, if available. Otherwise, * null. */ public EolAssertionException(String reason, ModuleElement ast, Object expected, Object actual, Object delta) { super(reason, ast); this.expected = expected; this.actual = actual; this.delta = delta; } /** * Returns the expected value, or null if not available. */ public Object getExpected() { return expected; } /** * Returns the actual value, or null if not available. */ public Object getActual() { return actual; } /** * Returns the precomputed difference between the expected and the actual * value, or null if not available. */ public Object getDelta() { return delta; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy