Specflow Add new step to existing feature file - specflow

I am new to SpecFlow and I've hit a strange issue.
I have an existing SpecFlow feature and step file. I want to add a new step and when I do this it shows the new step as unbound (purple). Then within Visual Studio 2015 I chose the option 'Generate Step Definitions', it selected the existing step file but then overwrote the file and I lost all the existing steps but my new one was added, how do I just append this new step without losing the existing steps?
Thank you

There are a couple of other alternatives to the one you outlined
One is to go to the 'Generate Step Definitions' dialogue on on there you can select the steps you want to generate the definitions for then click the 'Copy methods to clipboard' button rather than 'Generate', and then paste the methods into the existing step file. IMHO this should be the default option.
The other is to run the tests and check the output, where a the definition required will be part of the failing test output. This option is more viable if you are using a continuous test runner like NCrunch.

Sam has the correct flow. You want to generate the definitions the first time around and then after if step page is already created you will want to copy the steps. If you generate on a page that is already created, it will overwrite the existing steps page and you will lose any changes you made.

I worked out how to do it, for those who are new like me you have to choose the option 'Go To Step Definition' and you will see a snippet code which you must then say 'Yes' to copy to clipboard and then paste the code inside your existing step file.

Related

How do you edit Custom Build Definition Template using TFS 2017?

If I create a custom Build Definition Template from the context menu below, how does one actually edit it?
I can see I can delete it, but not edit. Are Overwrite or Delete & Recreate the only means to edit the Template? Seems a little severe... Neither option seems to give me historical tracking...
Or am I missing something obvious?
As I read https://www.visualstudio.com/en-us/articles/news/features-timeline this is a new feature in the initial phase that will be enhanced with 2017 Update 2 and later (honestly I haven't noticed it arrived in Update 1).
It seems like you actually can "edit" them, by creating a new template with the same name and basically overwrite the old one.
So you could:
Create a new build definition, using your existing template.
Make changes
Create a new template from the build definition with the same name as your current template.
All according to MSDN

TFS Build - Not including latest changeset

I have a custom TFS Build template that includes a procedure that runs a process that involves getting some data from a server and checking it into TFS before moving onto the main build process.
The steps are as follows:
Set build number
Run our custom script - get data, check into TFS
Initialize environment
Get sources from Team Foundation Version Control
Associate the changesets that occurred since the last good build
Compile, Test and Publish
The issue I appear to be having is that all change sets since the last successful build are included, except, the change set associated with the script run at step 2.
Does anyone know what could be going on here? my guess is that the logic that is looking for the change sets since last build is using a cut off that is set at the moment the build is requested (hence why the last change set is ignored) but this is just an uneducated guess.
Thanks in advance for your help.
Trying the steps below:
Edit your build definition and go to "Process" tab.
Enter "T" under "Get version" option.
Queue the build and check the result.
I would have two builds chained: the first build generates and check-in the files the second simply pulls them down.

Better way to update custom activities binaries

Currently I have few custom activities in the main build template. Each additional activity is stored in same binary but different class. To update binary I need to delete old one, check-in delete, copy manually from bin folder to tfs build controller folder, add items to source control and check in changes.
I would like to prevent problem of missing custom activities binary from build template while doing this process.
Can I do it any other way. So there is no time when binary doesn't exist in source control.
You can easily check in the new DLL over the top of the previous one.
If you are using a local Workspace then you just drop the new DLL on top of the old one. This can be automated with a post build script.
If you are using a server workspace (and files are read only) then you will need to check out the file before copying the new one over the top.
You can have an automated build that automated this entire process.
Usually, you should have two projects in your solution. One of the projects is for the custom code and custom activities, the other one to modify the build process template.
After you modify the process template, you need to check in process template and custom activities. The custom activities path should have been specified in your build controller.
Check this blog on how to create your own activity: http://www.ewaldhofman.nl/post/2010/04/29/customize-team-build-2010-e28093-part-4-create-your-own-activity.aspx

Is there a way to "Queue new Build" and override the output created by the Build Number Format

We are running TFS 2013 update 3 with Git - We have a powershell script that uses the output created by the BuildNumberFormat (environment variable TF_BUILD_BUILDNUMBER) that is generated at the time a build is executed. We also want to be able to queue a new build, and override that auto-generated BuildNumber, and specify a alternate (targeted hotfix for a previous tree / branch). With the default build template, there is no option to change the Build Number format (where we can statically set the desired value).
Our Build template:
Queue New Build template where we are targeting a specific changeset:
So the question is -- Do I need to edit the build work flow xaml to add this option as something that is passed in or is there a simpler way? I would like not to have to edit my power shell scripts that depend on this if we can. Ideas are greatly appreciated.
I ended up figuring it out, and it was incredibly easy. This may be an answer for similar questions also.
Copy the default build template (you can press download)
Place the file in your Repo path such as /BuildProcessTemplates/companyName.GitTemplate.12.xaml
Open the new xaml file in visual studios.
At the bottom of the screen, click the "Arguments"
Scroll down to "Metadata" and click on the edit button on the right
Scroll down to BuildNumberFormat - select it, and on the drop down "View this parameter when", change it to "Always Show the parameter"
Save the template, Commit it to your Git repo, push to your Git server.
Update your build Definition to use your new build template
You can now specify your own BuildNumber
Hope this helps someone. Looks useful for the other variables available in the build template.

How can I copy & paste, or duplicate, an existing project?

I've got an existing Hudson project that is configured and working.
I need to duplicate the project so that I can have the original and then change the new one so that it points to a different source control.
I don't want to manually recreate the build. How can i "copy & paste" or otherwise duplicate the exiting build configuration, so I can get the new build configuration up and running faster?
Click on "new job" and then select "Copy existing job" at the bottom. Then enter the name of the job you want to copy into the text field.
In addition to copying a job, I sometimes copy parts of the XML file that contains the job configuration. You just paste the copied part into the xml file of the new job and reload the configuration (under manage hudson). This is helpful when you change the original job after you created your copy. However, for your use case the copy is the right thing to do.
When you do new job, you can make the choice to copy it from an existing job. Later alter the settings of the new job.

Resources