- 1.Demo背景
- 2.核心的代码
- 3.将代码上传到Azure平台---(第一次上传代码)
- 4.本地修改代码之后,如何push到Azure
- (1)通过界面提交代码
- (2)通过命令行提交代码
1.Demo背景
本项目只是最最基础的一个Specflow框架的应用,后续会在此项目上叠加其他功能。如果有错误或不足之处,烦请指正,毕竟我也刚入门!
【项目的结构】
2.核心的代码
// Calculator.cs
namespace SpecFlowCalculator
{
public class Calculator
{
public int FirstNumber { get; set; }
public int SecondNumber { get; set; }
public int Add()
{
return FirstNumber + SecondNumber;
}
public int Subtract()
{
return FirstNumber - SecondNumber;
}
public int Multiply()
{
return FirstNumber * SecondNumber;
}
public int Divide()
{
return FirstNumber / SecondNumber;
}
}
}
// Calculator.feature
@Alien @smoke
Feature: Common math calculator(add/subtract/multiply/divide)
Scenario: Add two numbers
Given the first number is 50
And the second number is 70
When the two numbers are added
Then the result should be 120
Scenario: Subtract two numbers
Given the first number is 100
And the second number is 20
When first number subtract second number
Then the result should be 80
Scenario: Multiple two numbers
Given the first number is 3
And the second number is 20
When the two numbers are multiply
Then the result should be 60
Scenario: Divide two numbers
Given the first number is 66
And the second number is 6
When the two numbers are divide
Then the result should be 11
// CalculatorStepDefinitions.cs
using FluentAssertions;
using TechTalk.SpecFlow;
namespace SpecFlowCalculator.Specs.StepDefinitions
{
[Binding]
public sealed class CalculatorStepDefinitions
{
// For additional details on SpecFlow step definitions see https://go.specflow.org/doc-stepdef
private readonly ScenarioContext _scenarioContext;
private readonly Calculator _calculator = new Calculator();
public CalculatorStepDefinitions(ScenarioContext scenarioContext)
{
_scenarioContext = scenarioContext;
}
[Given("the first number is (.*)")]
public void GivenTheFirstNumberIs(int number)
{
_calculator.FirstNumber = number;
}
[Given("the second number is (.*)")]
public void GivenTheSecondNumberIs(int number)
{
_calculator.SecondNumber = number;
}
private int _result;
[When("the two numbers are added")]
public void WhenTheTwoNumbersAreAdded()
{
_result = _calculator.Add();
}
[Then("the result should be (.*)")]
public void ThenTheResultShouldBe(int result)
{
_result.Should().Be(result);
}
[When("first number subtract second number")]
public void WhenTheTwoNumbersAreSubtract()
{
_result = _calculator.Subtract();
}
[When("the two numbers are multiply")]
public void WhenTheTwoNumbersAreMultiply()
{
_result = _calculator.Multiply();
}
[When("the two numbers are divide")]
public void WhenTheTwoNumbersAreDivide()
{
_result = _calculator.Divide();
}
}
}
3.将代码上传到Azure平台—(第一次上传代码)
首先需要注册一个Azure的账号,如果你有微软的账号就不用重新注册了。
https://dev.azure.com/
【step1:注册页面】
【step2:注册之后】
复制如上的仓库地址,下面步骤中会使用到!
【step3:更新VS Studio本地的远程信息】
这一步会在本地更新成功,就说明你本地可以与远程仓库建立联系了。
【step4:将本地写的代码与远程仓库建立同步】
由于我本地项目已经有仓库了,远程也有仓库了,只是两个之间没有建立联系,所以选择【Existing remote即可】
去Azure平台查看,发现代码已经上传到仓库了!
4.本地修改代码之后,如何push到Azure
(1)通过界面提交代码
本地修改完代码,自己保存代码即可。后续都可以用界面 *** 作了!
commit info 是你需要填写的提交信息
changes 这里体现了你修改的文件信息,此处只改了一个文件
我本次希望把commit & push 分为2步完成,故中间那个选项选择了【Commit All】,然后点击这个按钮即可commit了
- commit 之后效果如上,可以点击如上箭头即可Push到远程仓库了
(2)通过命令行提交代码
使用git commit -m “ahisdfasdfas” 以及 git push master 即可上传到远程分支了
【提交到远程分支的效果】
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)