0

我正在尝试为基于摇摆的应用程序选择一个 Gui 测试框架工具。我开始查看 FEST 并创建了一个演示程序来检查运行时间有多快。

我的演示程序(下面的代码)花了大约 85000 毫秒才能完成,这对我来说似乎很慢。

所以我的问题是这是 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);
    }
}
4

1 回答 1

0

夹具有一个 settings() 函数,该函数返回存储延迟时间的设置对象。

将该时间更改为更合适的值:

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

FEST 似乎要等待 JVM 上的所有处理完成,然后才能进行下一步的测试。

此设置是在不等待所有内容停止的情况下尝试下一步的超时(在我的情况下它永远不会停止,我不知道为什么)。因此 FEST 总是属于默认为 10000 毫秒(或 10 秒)的超时子句。

您必须在设置中找出每种操作类型的值。

这取决于您的硬件和程序计算的内容量。

注意:main.settings()我的代码中的 是指您的final FrameFixture main,而不是 main 方法。

于 2015-05-06T18:13:23.317 回答