C#Assert.IsTrue和Assert.AreEquals的Java替代代码?

时间:2015-12-23 04:36:06

标签: java selenium assert

在C#中:

  Assert.IsTrue(NewPagePost.IsInEditMode(), ""wasn't in edit mode");

  Assert.AreEqual("Sample Page", NewPostPage.Title, "Title did not match");

Assert.IsTrue和Assert.AreEqual的Java替代方案是什么?

以下代码是否正确:

   Assert.assertTrue("wasn't in edit mode", NewPostPage.IsInEditMode());
   Assert.assertEquals("Sample Page,", NewPostPage.getTitle(),"Title did not match");

1 个答案:

答案 0 :(得分:1)

Assert.assertTrue("wasn't in edit mode", NewPostPage.IsInEditMode());
Assert.assertEquals("Sample Page,", NewPostPage.getTitle(),"Title did not match");

以上看起来不错。

您可以将第二个语句重写为

Assert.assertTrue("Sample Page".equals(NewPostPage.getTitle()),"Title did not match");