Giter Club home page Giter Club logo

test-clj.testng's Introduction

test-clj.testng is a small library that allows Clojure functions to be run as TestNG tests. It works by generating java classes (using Clojure's built-in gen-class function) that have TestNG annotations.

Usage:

(ns my.tests
  (:use [test-clj.testng :only (gen-class-testng)])
  (:import [org.testng.annotations Test BeforeClass]))

(defn ^{BeforeClass {}}
  setup [_]
  (do-setup-stuff))

(defn ^{Test {:groups ["mytests"]}}
  simple_test [_]
  (do-my-stuff))

(gen-class-testng)

Note several things:

  • Import of testng annotation classes you intend to use
  • Adding those annotations as metadata on the functions you want to use as tests
  • Call to gen-class-testng at the end
  • Each function needs to accept one argument (at runtime this will be the instance of the generated class). Often you will not need this argument, so the Clojure convention is to call it "_" when it is unused.
  • You will need to AOT compile your Clojure files that call (gen-class-testng), once they are compiled, testng will run them just as any other java class.

test-clj.testng's People

Contributors

lorquas avatar

Stargazers

Philipp Fehre avatar Lukasz Wiechec avatar Khaled avatar

Watchers

James Cloos avatar Craig Donnelly avatar NIKHIL DHANDRE avatar  avatar

Forkers

jstavel

test-clj.testng's Issues

Running TestNG using Ant against the .class files generated by the compile function.

Hello,

I was wondering how can I get the testNG framework (using Ant) to run the .class test files generated. So far, when I run ant, this is the error I receive:

Exception in thread "main" org.testng.TestNGException: 
   [testng] Cannot load class from file <path-to-file>
   [testng]     at org.testng.internal.ClassHelper.fileToClass(ClassHelper.java:600)
   [testng]     at org.testng.TestNG.configure(TestNG.java:1367)
   [testng]     at org.testng.TestNG.privateMain(TestNG.java:1328)
   [testng]     at org.testng.TestNG.main(TestNG.java:1307)

Here is my build.xml config:

<project name="proj-name" default="dist" basedir=".">
   <description>testNG testing</description>

   <taskdef name="testng" classname="org.testng.TestNGAntTask">
        <classpath>
            <pathelement location="<path>/testng-6.8.jar"/>
        </classpath>
    </taskdef>
    <testng haltOnFailure="true" verbose="2">
      <classfileset dir="<path>/test/" includes="tst.class" />
    </testng>
</project>

Any help would be great!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.