comment créer des fonctions génériques qui pourraient être appelées à partir de chaque test java? Dans ma fonction startappli je:junit4 fonctions
public class startappli{
public void testMain (String[] args)
{
String[] logInfos = new String[3];
logInfos[0] = (String) args[0];
logInfos[1] = (String) args[1];
}
@BeforeClass
public static void setupOnce() {
final Thread thread = new Thread() {
public void run() {
entrypointtoGUI.main(new String[]{"arg0 ", "arg1"});
}
};
try {
thread.start();
} catch (Exception ex) {
}
}
}
dans le toto.java, j'appelle la fonction comme suit: startappli.testmain (loginfo) il ne fonctionne pas aide?
ma fonction: Runner.java contient: public class RunAppli {
@BeforeClass setupOnce public static void() { fil de discussion final = new Thread() { public void run() {
Main.main(new String[]{"-rtebase ", "C:\\bin"});
}
};
try {
thread.start();
} catch (Exception ex) {
}
}
@Test public void Test() {
URL path = this.getClass().getResource("../Tester/map.xml");
System.out.println("Cover: " + cmapURL);
}
}
}
et à partir de mon test java TestDemo.java, j'appelle StartAppli QUI lance l'interface utilisateur graphique: RunAppli .setupOnce(); et je reçois le chemin d'accès au fichier xml: RunAppli .path devrions-nous utiliser @Test dans les fonctions? une suggestion? merci
Soyez spécifique. Plutôt que «ça ne marche pas», dites ce qui s'est réellement passé, et ce que vous attendiez et ce que vous essayez de faire. En outre, votre indentation a mal tourné, pouvez-vous l'éditer? –
@lamisse vous êtes censé accepter une réponse si cela vous convient. – Bozho