org.testng.Assert.assertEqualsNoOrder()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(9.8k)|赞(0)|评价(0)|浏览(454)

本文整理了Java中org.testng.Assert.assertEqualsNoOrder()方法的一些代码示例,展示了Assert.assertEqualsNoOrder()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Assert.assertEqualsNoOrder()方法的具体详情如下:
包路径:org.testng.Assert
类名称:Assert
方法名:assertEqualsNoOrder

Assert.assertEqualsNoOrder介绍

[英]Asserts that two arrays contain the same elements in no particular order. If they do not, an AssertionError is thrown.
[中]断言两个数组不按特定顺序包含相同的元素。如果没有,则抛出断言错误。

代码示例

代码示例来源:origin: org.testng/testng

@Override
 public void doAssert() {
  org.testng.Assert.assertEqualsNoOrder(actual, expected);
 }
});

代码示例来源:origin: org.testng/testng

@Override
 public void doAssert() {
  org.testng.Assert.assertEqualsNoOrder(actual, expected, message);
 }
});

代码示例来源:origin: org.testng/testng

/**
 * Asserts that two arrays contain the same elements in no particular order. If they do not,
 * an AssertionError is thrown.
 * @param actual the actual value
 * @param expected the expected value
 */
public static void assertEqualsNoOrder(Object[] actual, Object[] expected) {
 assertEqualsNoOrder(actual, expected, null);
}

代码示例来源:origin: cbeust/testng

@Override
 public void doAssert() {
  org.testng.Assert.assertEqualsNoOrder(actual, expected, message);
 }
});

代码示例来源:origin: cbeust/testng

@Override
 public void doAssert() {
  org.testng.Assert.assertEqualsNoOrder(actual, expected);
 }
});

代码示例来源:origin: cbeust/testng

/**
 * Asserts that two arrays contain the same elements in no particular order. If they do not, an
 * AssertionError is thrown.
 *
 * @param actual the actual value
 * @param expected the expected value
 */
public static void assertEqualsNoOrder(Object[] actual, Object[] expected) {
 assertEqualsNoOrder(actual, expected, null);
}

代码示例来源:origin: cbeust/testng

@Test
public void noOrderSuccess() {
 String[] rto1 = { "boolean", "BigInteger", "List",};
 String[] rto2 = {  "List", "BigInteger", "boolean",};
 Assert.assertEqualsNoOrder(rto1, rto2);
}

代码示例来源:origin: cbeust/testng

@Test(expectedExceptions = AssertionError.class)
public void noOrderFailure() {
 String[] rto1 = { "a", "a", "b",};
 String[] rto2 = {  "a", "b", "b",};
 Assert.assertEqualsNoOrder(rto1, rto2);
}

代码示例来源:origin: cbeust/testng

@Test
public void nullObjectArrayAssertNoOrder() {
 Object[] expected= null;
 Object[] actual= null;
 Assert.assertEqualsNoOrder(actual, expected);
}

代码示例来源:origin: cbeust/testng

@Test
public void verifyTestDependsOnGroupsInheritance() throws SecurityException, NoSuchMethodException {
 Map<String, List<String>> dataset = new HashMap<>();
 dataset.put("dependsOnGroups1", Arrays.asList("dog2", "dog1", "dog3"));
 dataset.put("dependsOnGroups2", Arrays.asList("dog1", "dog3"));
 for (Map.Entry<String, List<String>> data : dataset.entrySet()) {
  Method method = MTest3.class.getMethod(data.getKey());
  ITestAnnotation test1 = m_finder.findAnnotation(method, ITestAnnotation.class);
  List<String> expected = data.getValue();
  Assert.assertEqualsNoOrder(expected.toArray(new String[expected.size()]), test1.getDependsOnGroups());
 }
}

代码示例来源:origin: cbeust/testng

protected static void verifyInstanceNames(Map<String, List<ITestResult>> actual,
  String[] expected)
{
 List<String> actualNames = Lists.newArrayList();
 for (Map.Entry<String, List<ITestResult>> es : actual.entrySet()) {
  for (ITestResult tr : es.getValue()) {
   Object instance = tr.getInstance();
   actualNames.add(es.getKey() + "#" + (instance != null ? instance.toString() : ""));
  }
 }
 Assert.assertEqualsNoOrder(actualNames.toArray(), expected);
}

代码示例来源:origin: cbeust/testng

@Test
public void verifyTestGroupsInheritance() throws SecurityException, NoSuchMethodException {
 Map<String, List<String>> dataset = new HashMap<>();
 dataset.put("groups1", Arrays.asList("method-test3", "child-class-test3", "base-class"));
 dataset.put("groups2", Arrays.asList("child-class-test3", "base-class"));
 for (Map.Entry<String, List<String>> data : dataset.entrySet()) {
  Method method = MTest3.class.getMethod(data.getKey());
  ITestAnnotation test1 = m_finder.findAnnotation(method, ITestAnnotation.class);
  List<String> expected = data.getValue();
  Assert.assertEqualsNoOrder(expected.toArray(new String[expected.size()]), test1.getGroups());
 }
}

代码示例来源:origin: cbeust/testng

@Test
public void verifyTestDependsOnMethodsInheritance() throws SecurityException, NoSuchMethodException {
 Map<String, List<String>> dataset = new HashMap<>();
 dataset.put("dependsOnMethods1", Arrays.asList("dom2", "dom3", "dom1"));
 dataset.put("dependsOnMethods2", Arrays.asList("dom1", "dom3"));
 for (Map.Entry<String, List<String>> data : dataset.entrySet()) {
  Method method = MTest3.class.getMethod(data.getKey());
  ITestAnnotation test1 = m_finder.findAnnotation(method, ITestAnnotation.class);
  List<String> expected = data.getValue();
  Assert.assertEqualsNoOrder(expected.toArray(new String[expected.size()]), test1.getDependsOnMethods());
 }
}

代码示例来源:origin: cbeust/testng

@Test
public void verifyConfigurationGroupsInheritance() throws SecurityException, NoSuchMethodException {
 Method method = MTest3.class.getMethod("beforeSuite");
 IConfigurationAnnotation test1 = (IConfigurationAnnotation) m_finder.findAnnotation(method, IBeforeSuite.class);
 Assert.assertEqualsNoOrder(new String[] { "method-test3"}, test1.getGroups());
}

代码示例来源:origin: cbeust/testng

public void verifyTestMethodLevel() throws SecurityException, NoSuchMethodException
{
 //
 // Tests on MTest1SampleTest
 //
 Method method = MTest1.class.getMethod("f");
 ITestAnnotation test1 = m_finder.findAnnotation(method, ITestAnnotation.class);
 Assert.assertTrue(test1.getEnabled());
 Assert.assertEqualsNoOrder(test1.getGroups(), new String[] { "group1", "group3", "group4", "group2" });
 Assert.assertTrue(test1.getAlwaysRun());
 Assert.assertEqualsNoOrder(test1.getDependsOnGroups(), new String[] { "dg1", "dg2", "dg3", "dg4" });
 Assert.assertEqualsNoOrder(test1.getDependsOnMethods(), new String[] { "dm1", "dm2", "dm3", "dm4" });
 Assert.assertEquals(test1.getTimeOut(), 142);
 Assert.assertEquals(test1.getInvocationCount(), 143);
 Assert.assertEquals(test1.getSuccessPercentage(), 61);
 Assert.assertEquals(test1.getDataProvider(), "dp2");
 Assert.assertEquals(test1.getDescription(), "Method description");
 Class[] exceptions = test1.getExpectedExceptions();
 Assert.assertEquals(exceptions.length, 1);
 Assert.assertEquals(exceptions[0], NullPointerException.class);
}

代码示例来源:origin: cbeust/testng

@Test(invocationCount = 500)
 public void testInvocationCounterIsCorrectForMethodWithDataProvider() {
  final TestNG tng = create(FailedDPTest.class);
  tng.setThreadCount(1);
  tng.setParallel(XmlSuite.ParallelMode.NONE);
  tng.setPreserveOrder(true);
  final TestListenerAdapter tla = new TestListenerAdapter();
  tng.addListener((ITestNGListener) tla);
  tng.run();

  ITestNGMethod method = tla.getTestContexts().get(0).getAllTestMethods()[0];

  List<Integer> failed = method.getFailedInvocationNumbers();
  assertEqualsNoOrder(failed.toArray(), FailedDPTest.primes.toArray());
 }
}

代码示例来源:origin: cbeust/testng

public void verifyTestClassLevel() {
 //
 // Tests on MTest1SampleTest
 //
 ITestAnnotation test1 = m_finder.findAnnotation(MTest1.class, ITestAnnotation.class);
 Assert.assertTrue(test1.getEnabled());
 Assert.assertEquals(test1.getGroups(), new String[] { "group1", "group2" });
 Assert.assertTrue(test1.getAlwaysRun());
 Assert.assertEqualsNoOrder(test1.getDependsOnGroups(), new String[] { "dg1", "dg2" },  "depends on groups");
 Assert.assertEqualsNoOrder( test1.getDependsOnMethods(), new String[] { "dm1", "dm2" });
 Assert.assertEquals(test1.getTimeOut(), 42);
 Assert.assertEquals(test1.getInvocationCount(), 43);
 Assert.assertEquals(test1.getSuccessPercentage(), 44);
 Assert.assertEquals(test1.getThreadPoolSize(), 3);
 Assert.assertEquals(test1.getDataProvider(), "dp");
 Assert.assertEquals(test1.getDescription(), "Class level description");
 //
 // Tests on MTest1SampleTest (test defaults)
 //
 ITestAnnotation test2 = m_finder.findAnnotation(MTest2.class, ITestAnnotation.class);
 // test default for enabled
 Assert.assertTrue(test2.getEnabled());
 Assert.assertFalse(test2.getAlwaysRun());
 Assert.assertEquals(test2.getTimeOut(), 0);
 Assert.assertEquals(test2.getInvocationCount(), 1);
 Assert.assertEquals(test2.getSuccessPercentage(), 100);
 Assert.assertEquals(test2.getDataProvider(), "");
}

代码示例来源:origin: linkedin/URL-Detector

private void runTest(String text, UrlDetectorOptions options, String... expected) {
  //do the detection
  UrlDetector parser = new UrlDetector(text, options);
  List<Url> found = parser.detect();
  String[] foundArray = new String[found.size()];
  for (int i = 0; i < foundArray.length; i++) {
   foundArray[i] = found.get(i).getOriginalUrl();
  }

  Assert.assertEqualsNoOrder(foundArray, expected);
 }
}

代码示例来源:origin: samtools/htsjdk

@Test
public void testCopyDirectoryTree() throws IOException {
  final Path copyToDir = Files.createTempDirectory("copyToDir");
  copyToDir.toFile().deleteOnExit();
  IOUtil.copyDirectoryTree(TEST_VARIANT_DIR.toFile(), copyToDir.toFile());
  final List<Path> collect = Files.walk(TEST_VARIANT_DIR).filter(f -> !f.equals(TEST_VARIANT_DIR)).map(p -> p.getFileName()).collect(Collectors.toList());
  final List<Path> collectCopy = Files.walk(copyToDir).filter(f -> !f.equals(copyToDir)).map(p -> p.getFileName()).collect(Collectors.toList());
  Assert.assertEqualsNoOrder(collect.toArray(), collectCopy.toArray());
}

代码示例来源:origin: linkedin/transport

private void assertGetTypeVariableConstraints(List<String> inputParameterSignatures, String outputParameterSignature,
  List<TypeVariableConstraint> expectedTypeVariableConstraints) {
 ExampleStdUDF exampleStdUDF = new ExampleStdUDF(inputParameterSignatures, outputParameterSignature);
 Assert.assertEqualsNoOrder(StdUdfWrapper.getTypeVariableConstraintsForStdUdf(exampleStdUDF).toArray(),
   expectedTypeVariableConstraints.toArray());
}

相关文章