2016-04-10 17 views
1

私は簡単なアプリケーションを持っています。ユーザーがログインボタンをクリックすると メッセージがstdoutに出力されます。私はtestfxの使用を開始しようとしていますが、ボタンのクリックをシミュレートすると、 メッセージは表示されません。これは期待された動作ですか、または私が行方不明のものがありますか?testfxが標準出力に印刷していません

DialogioController.java

DialogioTest.java

import org.loadui.testfx.GuiTest; 
import java.io.IOException; 
import java.net.URL; 
import javafx.stage.Stage; 
import javafx.scene.Scene; 
import javafx.scene.Parent; 
import javafx.fxml.FXMLLoader; 
import org.junit.Test; 
import javafx.scene.control.Button; 
import javafx.scene.control.ToggleButton; 
import javafx.scene.control.TextField; 

public class DialogioTest extends GuiTest{ 
    @Override 
    protected Parent getRootNode() { 
     Parent parent = null; 
     try { 
      parent = FXMLLoader.load(getClass().getResource("Dialogio.fxml")); 
      System.out.println("Loaded parent"); 
      return parent; 
     } catch (IOException exc) { 
      exc.printStackTrace(); 
     } 
     return parent; 
    } 
    @Test 
    public void clickLogin(){ 
     Button loginButton = find("#loginButton"); 
     click(loginButton); 
    } 
} 

Dialogio.java

package dialogio; 
import javafx.application.Application; 
import java.net.URL; 
import javafx.stage.Stage; 
import javafx.scene.Scene; 
import javafx.scene.Parent; 
import javafx.fxml.FXMLLoader; 

public class Dialogio extends Application{ 
    public static void main(String[] args){ 
     launch(); 
    } 
    public void start(Stage primaryStage){ 
     primaryStage.setTitle("Dialogio"); 
     Parent root = null; 
     String sceneFile = "Dialogio.fxml"; 
     URL url = null; 
     try{ 
      url = getClass().getClassLoader().getResource(sceneFile); 
      root = FXMLLoader.load(url); 
      Scene scene = new Scene(root); 
      primaryStage.setScene(scene); 
      primaryStage.show(); 
     } 
     catch(Exception exc){ 
      exc.printStackTrace(); 
     } 
    } 
} 

Dialogio.fxml

<?xml version="1.0" encoding="UTF-8"?> 

<?import javafx.scene.control.Button?> 
<?import javafx.scene.control.ListView?> 
<?import javafx.scene.control.Tab?> 
<?import javafx.scene.control.TabPane?> 
<?import javafx.scene.control.TextField?> 
<?import javafx.scene.layout.AnchorPane?> 
<?import javafx.scene.layout.ColumnConstraints?> 
<?import javafx.scene.layout.GridPane?> 
<?import javafx.scene.layout.RowConstraints?> 


<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.76-ea" xmlns:fx="http://javafx.com/fxml/1" fx:controller="dialogio.DialogioController"> 
    <children> 
     <GridPane layoutX="14.0" layoutY="66.0" prefHeight="400.0" prefWidth="600.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> 
     <columnConstraints> 
      <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" /> 
      <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" /> 
      <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" /> 
      <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" /> 
     </columnConstraints> 
     <rowConstraints> 
      <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> 
      <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> 
      <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> 
     </rowConstraints> 
     <children> 
      <ListView fx:id="peopleList" prefHeight="200.0" prefWidth="200.0" GridPane.rowSpan="3" /> 
      <TabPane fx:id="tabList" prefHeight="134.0" prefWidth="353.0" tabClosingPolicy="UNAVAILABLE" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.rowSpan="3"> 
       <tabs> 
        <Tab text="Home"> 
        <content> 
         <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0"> 
          <children> 
           <GridPane layoutY="94.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0"> 
           <columnConstraints> 
            <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" /> 
           </columnConstraints> 
           <rowConstraints> 
            <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> 
            <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> 
            <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> 
            <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> 
           </rowConstraints> 
           <children> 
            <TextField fx:id="usernameField" promptText="username" /> 
            <TextField fx:id="passwordField" promptText="password" GridPane.rowIndex="1" /> 
            <TextField fx:id="ipField" promptText="server ip" GridPane.rowIndex="2" /> 
            <Button fx:id="loginButton" mnemonicParsing="false" onMouseClicked="#login" text="Login" textAlignment="CENTER" GridPane.rowIndex="3" /> 
           </children> 
           </GridPane> 
          </children> 
         </AnchorPane> 
        </content> 
        </Tab> 
       </tabs> 
      </TabPane> 
     </children> 
     </GridPane> 
    </children> 
</AnchorPane> 

答えて

1

私は私のbuild.gradle

test { 
    testLogging.showStandardStreams = true 
} 

を追加する必要が

関連する問題