Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我是 JUnit 测试的新手,我正在尝试创建一些测试来创建 JTable。我想知道是否有人可以指导我通过一些基本测试来创建 JTable?
非常感激 :)
我不确定您是否会专门测试表的创建,而是测试您填充它的数据。(除非您在运行时创建多个表,否则不会)
例如,假设您有两行数据要放入表中。
// Given JTable table = new JTable() //populate data etc. //When int rowCount = table.getRows() etc. //Then assertEquals(2, rowCount);
请记住您实际测试的是什么。小心不要偏离正题,开始测试不需要/不打算测试的东西。