bdd

Should I change the naming convention for my unit tests?

血红的双手。 提交于 2019-12-04 01:18:28
I currently use a simple convention for my unit tests. If I have a class named "EmployeeReader", I create a test class named "EmployeeReader.Tests. I then create all the tests for the class in the test class with names such as: Reading_Valid_Employee_Data_Correctly_Generates_Employee_Object Reading_Missing_Employee_Data_Throws_Invalid_Employee_ID_Exception and so on. I have recently been reading about a different type of naming convention used in BDD. I like the readability of this naming, to end up with a list of tests something like: When_Reading_Valid_Employee (fixture) Employee_Object_Is

How to set up individual tracing / logging with SpecFlow

夙愿已清 提交于 2019-12-03 22:15:29
For my SpecFlow tests, I want to setup an individual logging / tracing of the test progress during the execution of tests. E.g. i want to write all passed / failed steps started / ended scenarios started / ended features to the windows event log (in order to synchronize it with event log messages generated by other system components during the test). I tried to use the [BeforeFeature], [BeforeScenario], [BeforeStep] Hooks for doing that, but it turned out that I do not have all the required information within this hooks. E.g. i do not know how to get the current text line of the current step

Capybara - Submit a form without button

微笑、不失礼 提交于 2019-12-03 22:12:43
I am trying to submit a form without button using just Capybara and Rspec (no Cucumber or Selenium, I know there is already a question about that). I've seen there is a gist to add a method to submit a form without button: module SubmitRackTestFormWithoutButton def submit_form! Capybara::RackTest::Form.new(driver, form).submit({}) end end Capybara::RackTest::Node.send :include, SubmitRackTestFormWithoutButton https://gist.github.com/989533 , but I've not gotten it to work and I left a comment on it: I get undefined method `submit_form!' for #Capybara::Node::Element:... actually by "Capybara:

How to get an ActionContext from Struts 2 during acceptance tests?

情到浓时终转凉″ 提交于 2019-12-03 21:13:38
问题 I am writing acceptance tests (testing the behavior) using cucumber-jvm, on an application with Struts 2 and Tomcat as my Servlet Container. At some point in my code, I need to fetch the user from the Struts 2 HttpSession , created by an HttpServletRequest . Since I'm doing tests and not running Tomcat, I don't have an active session and I get a NullPointerException . Here's the code I need to call: public final static getActiveUser() { return (User) getSession().getAttribute("ACTIVE_USER");

Using BDD in API automation testing is a good aproach?

拟墨画扇 提交于 2019-12-03 17:25:37
I'm writing a framework for RESTful API test automation, I already decided to go with REST Assured, I'm not 100% sure about add a layer to allow define tests using a domain specific language like Gherkin, therefore adding a BDD framework like Cucumber. What is your opinion? Is a good approach to use BDD in API automation testing? I am currently using BDD for RestAPI Testing. Here is pros and cons for BDD RestAPI Automation framework. Technology We used: Cucumber,Java,Rest-Assured and junit Following pros and cons are my own comment or personal view. It is based on my experience. Pros: Easy to

Testing: How to test that view contains desired data

纵然是瞬间 提交于 2019-12-03 16:37:14
Say a Chef can make Recipes, and Sous-Chefs can create Recipes that must be approved by a Head Chef. You want to test that, when a Head Chef views her homepage, she sees Recipes that she herself created. You also want to test that she sees there are Recipes awaiting her approval. I can think of two ways to do this: Test that the view contains certain words, like "Your recipes" and "Recipes awaiting your approval" Add unnecessary attributes to the html elements you're using so that you can check for an element with "id=recipe_1" or "data-for-the-sake-of-testing=1" I very much dislike both of

How to communicate between contexts in behat 3?

烂漫一生 提交于 2019-12-03 16:00:29
I can't use getMainContext() and getSubcontext($alias) in version 3 any more. What is the way to communicate between context in version 3. Are context traits the only way? # behat.yml default: suites: guest_features: paths: [ %paths.base%/features/web ] filters: { role: guest } contexts: [ GuestContext ] user_features: paths: [ %paths.base%/features/web ] filters: { role: member } contexts: [ MemberContext ] groupled_features: paths: [ %paths.base%/features/web ] filters: { role: grouplead} contexts: [ GroupleadContext ] admin_features: paths: [ %paths.base%/features/web ] filters: { role:

@Before doesn't execute in java Cucumber Step

こ雲淡風輕ζ 提交于 2019-12-03 11:58:17
问题 I've got a Cucumber Step class that i'm attempting to initialise a page model for all scenarios. So I added a @Before annotated method : @Before() private void beforeScenario() { LOGGER.info("Running before!"); loginPage = BrowserDriver.getPageModel(LoginPage.class); } I've then got a bunch of steps that rely on loginPage being set. e.g. @When("^I click the help link$") public void I_click_the_help_link() { loginPage.clickHelpLink(); } I have multiple Step classes. Both of the methods above

Specflow use parameters in a table with a Scenario Context

心不动则不痛 提交于 2019-12-03 11:58:00
I am using Specflow in C# to build automatic client side browser testing with Selenium. The goal of these tests is to simulate the business scenario where a client enters our website in specific pages, and then he is directed to the right page. I Want to use parameters inside a Scenario Context, for example: When I visit url | base | page | parameter1 | parameter2 | | http://www.stackoverflow.com | questions | <questionNumber> | <questionName> | Then browser contains test <questionNumber> Examples: | <questionNumber> | <questionName> | | 123 | specflow-q1 | | 456 | specflow-q2 | | 789 |

Checking ActiveRecord Associations in RSpec

让人想犯罪 __ 提交于 2019-12-03 11:21:57
问题 I am learning how to write test cases using Rspec. I have a simple Post Comments Scaffold where a Post can have many Comments. I am testing this using Rspec. How should i go about checking for Post :has_many :comments . Should I stub Post.comments method and then check this with by returning a mock object of array of comment objects? Is testing for AR associations really required ? 回答1: Since ActiveRecord associations should be well-tested by the Rails test suite (and they are), most people