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

io.github.carousell.cucumber2junit.model.Scenario Maven / Gradle / Ivy

Go to download

Generates plain JUnit tests from Gherkin feature files. This is useful when you want to execute Cucumber tests in an environment which does not allow custom JUnit runners, e.g. the AWS Device Farm.

The newest version!
package io.github.carousell.cucumber2junit.model;

import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import io.github.carousell.cucumber2junit.JavaUtils;
import java.util.List;

/** DTO for Gherkin scenarios. */
public class Scenario {

  private String id;
  private int lineNumber;
  private String name;
  private List tags;

  /**
   * Constructor.
   *
   * @param lineNumber line number of the scenario
   * @param name scenario name
   * @param tags {@link List} of tags
   */
  public Scenario(String id, int lineNumber, String name, List tags) {
    super();
    this.id=id;
    this.lineNumber = lineNumber;
    this.name = name;
    this.tags = tags;
  }

  public int getLineNumber() {
    return lineNumber;
  }

  public void setLineNumber(int lineNumber) {
    this.lineNumber = lineNumber;
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public List getTags() {
    return tags;
  }

  public void setTags(List tags) {
    this.tags = tags;
  }
  
  @Override
  public int hashCode() {
    return Objects.hashCode(name, lineNumber, tags);
  }
  
  @Override
  public boolean equals(Object obj) {
    if (obj == null) {
      return false;
    }
    if (obj == this) {
      return true;
    }
    if (obj.getClass() != getClass()) {
      return false;
    }
    Scenario other = (Scenario) obj;
    return Objects.equal(this.name, other.name)
        && Objects.equal(this.lineNumber, other.lineNumber)
        && Objects.equal(this.tags, other.tags);
  }
  
  @Override
  public String toString() {
    return MoreObjects.toStringHelper(this)
        .add("name", name)
        .add("lineNumber", lineNumber)
        .add("tags", tags)
        .toString();
  }
  
  /**
   * @return name used for the Java method
   */
  public String getJavaName() {
    return JavaUtils.toMethodName(name);
  }

  public String getId() {
    return id;
  }

  public void setId(String id) {
    this.id = id;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy