用黄瓜跑testrunner

时间:2017-04-21 21:50:12

标签: junit cucumber cucumber-junit

我在使用黄瓜运行testrunner时遇到问题。我需要有人帮我查一下@CucumberOptions。谢谢

                        string ip = "192.168.98.78";
                        Bitmap b = new Bitmap(SystemInformation.VirtualScreen.Width, SystemInformation.VirtualScreen.Height);
                        Graphics g = Graphics.FromImage(b);
                        Console.WriteLine("taking screenshot");
                        g.CopyFromScreen(0, 0, 0, 0, b.Size);
                        g.Dispose();

                                                    MemoryStream ms = new MemoryStream();

                        b.Save(ms, ImageFormat.Png);
                        byte[] bmp = ms.ToArray();

                        Console.WriteLine("sending pic");
                        do {
                            try
                            {
                                TcpClient tcpClient = new TcpClient(ip, 2000);
                            NetworkStream clientSockStream = tcpClient.GetStream();
                                Console.WriteLine("connecting to server");
                                StreamWriter clientStreamWriter = new StreamWriter(clientSockStream);
                                Console.WriteLine("send data");

                                    clientSockStream.Write(bmp, 0, 1024);

                                tcpClient.Close();
                                fertig = true;
                            } catch (Exception h)
                            {
                                Console.WriteLine(h.Message);
                            }

                        } while (fertig != true);

2 个答案:

答案 0 :(得分:0)

@RunWith(Cucumber.class)用于JUnit集成。 如果您想将Cucumber与TestNG一起使用,则必须使用AbstractTestNGCucumberTests扩展您的课程。

你应该看看https://github.com/lionhearth/cucumber-testng,这是一个完美的样本。

答案 1 :(得分:0)

这是我的测试。我在src中有两个步骤定义/ featurefiles作为包。此外,我下载了黄瓜插件,但我看不到我的功能中显示的颜色。如何参考特征和步骤定义@cucumberoptions。

package stepDefinition;

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


public class aptitudeTest {

    @Given ("^I have successfully ([^\"]*)$")
    public void I_have_(String str)
    {
        if (str.equals("registered"))
        {
            System.out.println("registered Automation");
        }
        if (str.equals("unregistered"))
        {
            System.out.println("unregistered");
        }
    }

    @When ("^I enter my valid ([^\"]*)$")
    public void I_enter_(String str)
    {
        if (str.equals("credentials"))
        {
            System.out.println("credentials Automation");
        }
        if (str.equals("details"))
        {
            System.out.println("details");
        }
    }

        @Then ("^I should see the welcome([^\"]*)him $")
        public void I_should_(String str)
        {
            if  (str.equals("message"))
            {
                System.out.println("message Automation");
            }
            if (str.equals("information"))
            {
                System.out.println("infomation");
            }
        }
    }

这是我的功能

功能:登录帐户

@tester 场景:我成功登录后会看到一条消息

鉴于我已成功注册 当我输入有效的凭证时 然后我应该看到欢迎信息

鉴于我已成功取消注册 当我输入有效的细节时 然后我应该看到欢迎信息

相关问题