QuBiT / cucumber-netbeans-plugin

Plugin / Module which allow Syntax Highlighting and many more in NetBeans with .feature Files
MIT License
50 stars 19 forks source link

can not run the cucumber as the junit test in the Netbeans #36

Closed jenny-zhen closed 8 years ago

jenny-zhen commented 8 years ago

My developing environment is :

After created the maven project with feature, runTest class and stepsTest. But when I tried to run the "runTest" as the test file within the netbeans, but I got "no test executed".

Here is the main project: (1) the project tree: capture (2) the RunTest.java:

package feature.salary; import cucumber.api.CucumberOptions; import org.junit.runner.RunWith; import cucumber.api.junit.Cucumber;

@RunWith(Cucumber.class) @CucumberOptions(features = "\src\test\resources\feature\salary", glue="src\test\java\feature\salary") public class RunTest {

}

(3) the SalaryTest.java: package feature.salary; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.IsEqual.equalTo;

import java.util.List;

import com.hascode.tutorial.cucumber.salary.Employee; import com.hascode.tutorial.cucumber.salary.SalaryManager;

import cucumber.api.java.en.Given; import cucumber.api.java.en.Then; import cucumber.api.java.en.When;

public class SalarySteps { SalaryManager manager;

@Given("^the salary management system is initialized with the following data$")
public void the_salary_management_system_is_initialized_with_the_following_data(final List<Employee> employees) throws Throwable {
    manager = new SalaryManager(employees);
}

@When("^the boss increases the salary for the employee with id '(\\d+)' by (\\d+)%$")
public void the_boss_increases_the_salary_for_the_employee_with_id_by(final int id, final int increaseInPercent) throws Throwable {
    manager.increaseSalary(id, increaseInPercent);
}

@Then("^the payroll for the employee with id '(\\d+)' should display a salary of (\\d+)$")
public void the_payroll_for_the_employee_with_id_should_display_a_salary_of(final int id, final float salary) throws Throwable {
    Employee nominee = manager.getPayroll(id);
    assertThat(nominee.getSalary(), equalTo(salary));
}    

}

(4) the salary_management.feature: Feature: Salary Management

Scenario: Modify an employee's salary Given the salary management system is initialized with the following data | id| user | salary| | 1 | donald | 60000 | | 2 | dewie | 62000 | | 3 | goofy | 55000 | | 4 | scrooge| 70000 | | 5 | daisy | 56000 | | 6 | minnie | 62000 | | 7 | mickey | 51000 | | 8 | fethry | 66500 |
When the boss increases the salary for ht eemployee with id '3' by 5% Then the payroll for the employee with id '3' should display a salary of 57750

The test result is: If I run "mvn test" in the command line, I can get the correct result. But if I right click on the "RunTest.java" and select "Test File", I only got "No tests executed."

Can anyone help me to check what should I do? Thanks. BTW., it works well in the Eclipse.