如何对使用 Java UUID 的代码进行单元测试?
2022-09-04 08:14:25
						我有一段代码,预计会用Java UUID()填充响应对象的一个属性。UUID.randomUUID()
如何从外部对此代码进行单元测试以检查此行为?我不知道在其中生成的UUID。
需要测试的示例代码:
// To test whether x attribute was set using an UUID
// instead of hardcode value in the response
class A {
  String x;
  String y;
}
// Method to test
public A doSomething() {
  // Does something
  A a = new A();
  a.setX( UUID.randomUUID());
  return a;
}