-2
如何为我编写的BinaryTree
类开发JUnit测试?如何使用Junit测试二叉树?
请提供建议或提供示例,以便我可以更好地了解如何在Junit中测试二叉树。
package binaryTree;
import javax.xml.soap.Node;
public class BinaryTree<T extends Comparable<T>> implements BTree<T> {
private TreeNode root;
Node current = (Node) root;
@Override
public void insert(T value) {
if (root == null) {
root = new TreeNode(value);
} else if (value.compareTo(value()) < 0) {
root.getleft().insert(value);
} else {
root.right().insert(value);
}
}
@Override
public T value() {
if (this.root != null) {
return (T) this.root.value();
} else {
return null;
}
}
@Override
public BTree<T> left() {
if (this.root != null) {
return this.root.getleft();
} else {
return null;
}
}
@Override
public BTree<T> right() {
if (this.root != null) {
return this.root.right();
} else {
return null;
}
}
}
我提供了一个简单的例子来测试一个虚拟的'add'函数。您需要导入您的'BinaryTree'类,并为此编写测试用例。也就是说,我认为你需要澄清你问:你不知道**如何测试二叉树**或**关于如何编写一个简单的JUnit测试**。赞赏https://stackoverflow.com/help/mcve最小,完整和可验证的例子 – sam