bdd

Should I change the naming convention for my unit tests?

こ雲淡風輕ζ 提交于 2019-12-05 15:28:59
问题 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

Multiple Match bindings found on line with two different parameters

你说的曾经没有我的故事 提交于 2019-12-05 15:22:59
I have written two lines(When's) in my same feature file When user $action1$ $key1$ with $value1$ for $atttributeType_Value$ in $Filename1_SectionId1$ Then abc When user $action2$ $key2$ with $value2$ in $Filename2_SectionId2$ Then def and corresponding step definition in step definition file as [When(@"user (.*) (.*) with (.*) for (.*) in (.*)")] public void abc() { //operation } [When(@"user (.*) (.*) with (.*) in (.*)")] public void def() { //operation } But, its showing up an error as "Multiple match bindings found. Navigating to first match.." When I try to navigate for 1st line its

Text in clipboard with protractor js

大兔子大兔子 提交于 2019-12-05 15:19:22
How can I copy a specific text with protractor ? I would like to load a text to paste after with this command : return browser.actions().sendKeys(Keys.CONTROL, 'v').perform(); Sample : Load my text "test" and after with this command, paste "test" I would like put a text in my clipboard alecxe can I put a value directly in my ng-model, not use sendKeys ? Yes, you can directly set the model value via .evaluate() : var elm = element(by.model("mymodel.field")); elm.evaluate("mymodel.field = 'test';"); Putting a text into clipboard The idea is to use an existing or dynamically create an input

Can I nest TestCases with Nose?

半城伤御伤魂 提交于 2019-12-05 14:38:12
I've become a fan of nested test case contexts in things like RSpec and Jasmine, and I'm wondering if there are any Nose plugins that implement a test finder that allows you to nest classes as context. The resulting tests would look something like the following: from nose.tools import * from mysystem import system_state class TestMySystem (TestCase): def setUp(self): system_state.initialize() class WhenItIsSetTo1 (TestCase): def setUp(self): system_state.set_to(1) def test_system_should_be_1 (self): assert_equal(system_state.value(), 1) class WhenItIsSetTo2 (TestCase): def setUp(self): system

Behave: How to import steps from another file?

好久不见. 提交于 2019-12-05 13:33:11
I have just started using behave , a Pythonic BDD framework using Gherkin syntax . behave takes a feature, e.g.: Scenario: Calling the metadata API Given A matching server When I call metadata Then metadata response is JSON And response status code is 200 And a steps file, e.g.: ... @then('response status code is {expected_status_code}') def step_impl(context, expected_status_code): assert_equals(context.response.status_code, int(expected_status_code)) @then('metadata response is JSON') def step_impl(context): json.loads(context.metadata_response.data) ... And combines them to a beautiful test

DRY-ing very similar specs for ASP.NET MVC controller action with MSpec (BDD guidelines)

依然范特西╮ 提交于 2019-12-05 10:56:04
I have two very similar specs for two very similar controller actions: VoteUp(int id) and VoteDown(int id). These methods allow a user to vote a post up or down; kinda like the vote up/down functionality for StackOverflow questions. The specs are: VoteDown: [Subject(typeof(SomeController))] public class When_user_clicks_the_vote_down_button_on_a_post : SomeControllerContext { Establish context = () => { post = PostFakes.VanillaPost(); post.Votes = 10; session.Setup(s => s.Single(Moq.It.IsAny<Expression<Func<Post, bool>>>())).Returns(post); session.Setup(s => s.CommitChanges()); }; Because of =

How do I set up NCrunch to run nspec tests

醉酒当歌 提交于 2019-12-05 09:11:19
I'm struggling to set up NCrunch to run my nspec tests automatically. On the ncrunch forums it says this functionality has not been implemented yet, but then MattFlo says he prefers using NCrunch, so I'm pretty sure it can be made to work. Help would be greatly appreciated! We are working on getting NCrunch fully supported. For now you can use the DebuggerShim (it's a cs file included with NSpec) as a shim to run it via NCrunch. The DebuggerShim is pretty much an NUnit test that runs NSpec tests. You may want to take a look at specwatchr . Matt likes to use NCruch, but I find that it's to

Capybara - Submit a form without button

断了今生、忘了曾经 提交于 2019-12-05 09:00:46
问题 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

I am having trouble testing my controller's update action using Rspec, what am I doing wrong?

我怕爱的太早我们不能终老 提交于 2019-12-05 08:01:01
问题 I am trying to test the failing branch of the update action on my controller but I am having trouble with the test. This is what I have and it fails on the last describe "PUT 'article/:id'" do . . . describe "with invalid params" do it "should find the article and return the object" do Article.stub(:find).with("1").and_return(@article) end it "should update the article with new attributes" do Article.stub(:update_attributes).and_return(false) end it "should render the edit form" do response

SpecFlow Visual Studio extension attempted to use SpecFlow code-behind generator 1.9

你。 提交于 2019-12-05 07:05:20
问题 I am getting the following error while trying to build my automation solution. Due to which i am unable to change anything in my feature file at the moment. error Version conflict - SpecFlow Visual Studio extension attempted to use SpecFlow code-behind generator 1.9, but project 'POC.Specs' references SpecFlow 2.0. error We recommend migrating to MSBuild code-behind generation to resolve this issue. error For more information see https://specflow.org/documentation/Generate-Tests-from-MsBuild/