
Ubuntu日本語フォーラム

ログインしていません。
NetBeansのメーリングリストにも問い合わせており、二重投稿になって申し訳ありませんが、自宅のUbuntu 7.10にNetBeans 6.0.1をインストールしまして、きしだなおき先生の「創るJava」(マイコミ=毎日コミュニケーションズ=社刊)でJavaを勉強しているのですが、JUnitでテストするとき(400頁以降)に、肝心のテストメソッドが作成されません。正確には下記のクラスが作成されるはずなのですが、public void twiceのメソッドが作成されません。
会社のUbuntu 7.10マシンやWindows XPでは問題なくテストメソッドが作成されます。
ですので、自宅のUbuntu 7.10に問題があるような気がしますが、どう対処して良いものでしょうか。
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package flow;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
/**
*
* @author michiaki
*/
public class MethodSampleTest {
public MethodSampleTest() {
}
@BeforeClass
public static void setUpClass() throws Exception {
}
@AfterClass
public static void tearDownClass() throws Exception {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
/**
* Test of twice method, of class MethodSample.
*/
@Test
public void twice() {
System.out.println("twice");
int value = 0;
MethodSample instance = new MethodSample();
int expResult = 0;
int result = instance.twice(value);
assertEquals(expResult, result);
assertEquals("3を2倍すると", 6, instance.twice(3));
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
* Test of main method, of class MethodSample.
*/
@Test
public void main() {
System.out.println("main");
String[] args = null;
MethodSample.main(args);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}なお、元のjavaプログラムは次のようなものです。
/*
* MethodSample.java
*
* Created on 2008/03/20, 22:42
*/
package flow;
/**
*
* @author seijun
*/
public class MethodSample extends javax.swing.JFrame {
/** Creates new form MethodSample */
public MethodSample() {
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
txtNumber = new javax.swing.JTextField();
btnCalc = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
taOutput = new javax.swing.JTextArea();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
btnCalc.setText("計算");
btnCalc.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnCalcActionPerformed(evt);
}
});
taOutput.setColumns(20);
taOutput.setRows(5);
jScrollPane1.setViewportView(taOutput);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(txtNumber, javax.swing.GroupLayout.PREFERRED_SIZE, 284, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnCalc, javax.swing.GroupLayout.DEFAULT_SIZE, 85, Short.MAX_VALUE)))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtNumber, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnCalc))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 253, Short.MAX_VALUE)
.addContainerGap())
);
pack();
}// </editor-fold>
int twice(int value) {
int result = value * 2;
//return 0;
return result;
}
private void btnCalcActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String str = txtNumber.getText();
int number = Integer.parseInt(str);
int bai = twice(number);
taOutput.append(number + "を2倍したら" + bai + "\n");
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new MethodSample().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton btnCalc;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextArea taOutput;
private javax.swing.JTextField txtNumber;
// End of variables declaration
}最後の編集者: seijun (2008-03-29 08:47:58)
オフライン
seijun による投稿:
NetBeansのメーリングリストにも問い合わせており、二重投稿になって申し訳ありませんが、
・「NetBeansのメーリングリスト」ではなく、当該メーリングリストのアーカイブページのURLを示しましょう。
・二重投稿であることは(ほとんど)問題ありません。しかし、その出典(というか、二重投稿した先)にたどり着くための
ポインタが示されていないことは大きな問題です。
よろしくお願いします。
オフライン
seijunです。
hito による投稿:
seijun による投稿:
NetBeansのメーリングリストにも問い合わせており、二重投稿になって申し訳ありませんが、
・「NetBeansのメーリングリスト」ではなく、当該メーリングリストのアーカイブページのURLを示しましょう。
・二重投稿であることは(ほとんど)問題ありません。しかし、その出典(というか、二重投稿した先)にたどり着くための
ポインタが示されていないことは大きな問題です。
よろしくお願いします。
「ポインタ」というものがよく分かりませず、まことに申し訳ない限りですが、
http://www.netbeans.org/servlets/Browse … ;count=118
で一連の流れはつかめるのではないかと思います。
検索してみると、次のURLが出てきました。
http://www.netbeans.org/servlets/Search … rch=Search
スレッドは次です。
http://www.netbeans.org/servlets/Browse … p;count=11
最後の編集者: seijun (2008-03-28 12:09:10)
オフライン