Home
Categories
Dictionary
Download
Project Details
Changes Log
What Links Here
How To
Syntax
FAQ
License

Structure of a unit test



This article explains the structure of a unit test.

Parsing a wiki source directory

  // get the directory for the wiki source
  ResourceLoader loader = new ResourceLoader("org/docgene/resources");
  URL url = loader.getURL("input105");
  File dir = new File(url.getFile());
  File[] dirs = new File[1];
  dirs[0] = dir;

  // parse the wiki source
  DefaultDirectoryParser parser = new DefaultDirectoryParser(false);
  parser.parseDirectoriesAndResolve(dirs);
      
  // check that there is no exception when parsing
  List<ResolverSAXHandler.ExceptionResult> exceptions = parser.getParserExceptions();
  assertTrue("The parser should not have any exceptions", exceptions.isEmpty());

  // get the model
  model = parser.getModel();
  assertNotNull("ArticlesModel should not be null", model);        

Ordering unit tests methods

Main Article: Ordering unit tests

In many of the unit test classes, the order of the execution of methods is important. For example, you may have a first method which parse a wiki source directry, and then several methods which check the content of the wiki tree. In that case, you might need to use the org.mdiutil.junit.OrderedRunner annotation.

See also


Categories: development

docJGenerator Copyright (c) 2016-2023 Herve Girod. All rights reserved.