Activator从套件测试中运行单一测试

时间:2016-07-20 23:57:57

标签: scala sbt scalatest typesafe-activator

大家都在我的游戏项目中创建了一套测试。

package tanks;

import java.util.Random;

public class Tanks extends javax.swing.JFrame {

    public Tanks() {
        initComponents();
        BrownTank();
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Tanks!");
        addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                formKeyPressed(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("PMingLiU", 1, 16)); // NOI18N
        jLabel1.setText("◻");

        jLabel2.setFont(new java.awt.Font("PMingLiU", 1, 18)); // NOI18N
        jLabel2.setForeground(new java.awt.Color(102, 51, 0));
        jLabel2.setText("◻");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(46, 46, 46)
                        .addComponent(jLabel2))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(244, 244, 244)
                        .addComponent(jLabel1)))
                .addContainerGap(315, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(24, 24, 24)
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 281, Short.MAX_VALUE)
                .addComponent(jLabel1)
                .addGap(89, 89, 89))
        );

        pack();
    }// </editor-fold>                        

    private void formKeyPressed(java.awt.event.KeyEvent evt) {                                
        int speed = 3;
        if (evt.getKeyChar() == 'w') {
            jLabel1.setBounds(jLabel1.getX(), jLabel1.getY() - speed, jLabel1.getWidth(), jLabel1.getHeight());
        }
        if (evt.getKeyChar() == 's') {
            jLabel1.setBounds(jLabel1.getX(), jLabel1.getY() + speed, jLabel1.getWidth(), jLabel1.getHeight());
        }
        if (evt.getKeyChar() == 'a') {
            jLabel1.setBounds(jLabel1.getX() - speed, jLabel1.getY(), jLabel1.getWidth(), jLabel1.getHeight());
        }
        if (evt.getKeyChar() == 'd') {
            jLabel1.setBounds(jLabel1.getX() + speed, jLabel1.getY(), jLabel1.getWidth(), jLabel1.getHeight());
        }
    }                               

    public void PlayerBullet() {

    }

    public void BrownTank() {
        while (true) {
            int speed = 2;
            Random randomGenerator = new Random();
            int Movement = randomGenerator.nextInt(4) + 1;
            if (Movement == 1) {
                jLabel2.setBounds(jLabel2.getX(), jLabel2.getY() - speed, jLabel2.getWidth(), jLabel2.getHeight());
            }

            if (Movement == 2) {
                jLabel2.setBounds(jLabel2.getX(), jLabel2.getY() + speed, jLabel2.getWidth(), jLabel2.getHeight());
            }

            if (Movement == 3) {
                jLabel2.setBounds(jLabel2.getX() - speed, jLabel2.getY(), jLabel2.getWidth(), jLabel2.getHeight());
            }

            if (Movement == 4) {
                jLabel2.setBounds(jLabel2.getX() + speed, jLabel2.getY(), jLabel2.getWidth(), jLabel2.getHeight());
            }
        }
    }

    public static void main(String args[]) {

        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Tanks().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify                     
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    // End of variables declaration                   
}

有没有办法指定套件来运行单个测试?现在,如果我想进行其中一项测试,我必须评论出我不想要的任何测试。这是我运行该套件的命令。

class AcceptanceSuite extends Suites(new SomeTest, new SomeTest2, new SomeTest3) with OneAppPerSuite

1 个答案:

答案 0 :(得分:1)

你试过吗

testOnly acceptance.SomeTest