简体   繁体   English

节日运行速度

[英]Fest running speed

I'm trying to select a Gui testing framework tool for a swing based application. 我正在尝试为基于swing的应用程序选择Gui测试框架工具。 I started to have a look on FEST and created a Demo program to check how fast the run time is. 我开始研究FEST,并创建了一个演示程序来检查运行时间有多快。

My demo program (code bellow) took about 85000 millisec to complete which appeared very slow to me. 我的演示程序(下面的代码)完成了大约85000毫秒,这对我来说似乎很慢。

So my question is this the normal speed of Fest ? 所以我的问题是这节日的正常速度吗?

public class DemoGui extends JFrame
{
    private JPanel contentPane;
    private JTextField textField;
    private JPanel panel;
    private JButton btnNewButton;
    private JButton btnRun;

    public static final int REPEAT = 10;

    public static void runX(final JFrame window)
    {
        final FrameFixture main = new FrameFixture(window);

        new Thread(new Runnable()
        {
            @Override
            public void run()
            {
                final long start = System.currentTimeMillis();
                for (int i = 0; i < REPEAT; i++)
                {
                    main.textBox().deleteText().setText("this is a test demo");
                    main.button(JButtonMatcher.withText("OK")).click();
                }
                final long end = System.currentTimeMillis();
                System.out.println("Exec Time : " + String.valueOf(end - start));

            }
        }).start();
    }


    public static void main(String[] args)
    {
        EventQueue.invokeLater(new Runnable()
        {
            public void run()
            {
                try
                {
                    DemoGui frame = new DemoGui();
                    frame.setVisible(true);
                }
                catch (Exception e)
                {
                    e.printStackTrace();
                }
            }
        });
    }

    /**
     * Create the frame.
     */
    public DemoGui()
    {
        setTitle("DemoGui");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setBounds(100, 100, 450, 300);
        contentPane = new JPanel();
        contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
        contentPane.setLayout(new BorderLayout(0, 0));
        setContentPane(contentPane);

        textField = new JTextField();
        contentPane.add(textField, BorderLayout.NORTH);
        textField.setColumns(10);

        panel = new JPanel();
        contentPane.add(panel, BorderLayout.SOUTH);

        btnRun = new JButton("run");
        btnRun.addActionListener(new ActionListener()
        {
            public void actionPerformed(ActionEvent e)
            {
                runX(DemoGui.this);
            }
        });
        panel.add(btnRun);

        btnNewButton = new JButton("OK");
        panel.add(btnNewButton);
    }
}

The fixture has a settings() function that returns the Settings object where the delay times are stored. 灯具具有settings()函数,该函数返回存储延迟时间的Settings对象。

Change that times to a more fitted value: 将该时间更改为更合适的值:

public static void main(String[] args)
{
    main.settings().idleTimeout(2000);

It seems that FEST waits for the finish of all processing on the JVM before you can go to the next step of the test. 看来FEST等待JVM上所有处理的完成,然后才能进行测试的下一步。

This setting is the timeout to try the next step without waiting for all the stuff to stop (in my case it never stops, and i dont know why). 此设置是尝试下一步而又不等待所有内容停止的超时时间(对于我而言,它永远也不会停止,我也不知道为什么)。 So FEST always fall into the timeout clause which by default is 10000ms (or 10s). 因此,FEST始终属于timeout子句,默认情况下为10000ms(或10s)。

You have to figure out the values for each type of operation in the settings. 您必须在设置中找出每种操作类型的值。

It will depends on your hardware and the amount of stuff your program computes. 这将取决于您的硬件和程序计算的内容量。

Note: The main.settings() in my code refers to your final FrameFixture main , not the main method. 注意:我的代码中的main.settings()是指final FrameFixture main ,而不是main方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM