Giter Site home page Giter Site logo

cljunit's Issues

Use cljunit in lein project

Is there an example of integrating cljunit within a lein project?

I can't figure out where the

import mikera.cljunit.ClojureTest;

public class ClojureTests extends ClojureTest {
	// filter namespaces with the given prefix
	@Override public String filter() {
	    return "com.mycompany";
	}
}

type code is supposed to go, or what it's supposed to look like, exactly.

Testing all namespaces by default not working

Hello there,

Thanks very much making cljunit available.

I am trying to use it within a maven build to wrap up a large suite of clojure tests, so that the surefire output can then be picked up by a CI tool and used within surefire reports.

I'm having no problems with the specific (and subset) namespace examples, however when I use the example usage that tests all namespaces by default, no tests are run for that class by junit.

I've noticed that if I check out cljunit and run mvn test (after modifying the surefire plugin within the pom to include "*_/_Tests.java" (so that cljunit/AllClojureTests is picked up), the same behaviour occurs.

In my project, my tests are located under src/test/clojure, and I have added

<testResources>
  <testResource>
    <directory>src/test/clojure</directory>
  </testResource>
</testResources>

to the pom so that they are copied to target/test-classes and thus included in the classpath when surefire runs.

If you have any suggestions, it would be appreciated. The specific namespace examples are great, but for a project with a large number of namespaces, you can imagine it's not maintainable to specify each and every one.

cheers,
Anth

cljunit doesn't pick up tests with maven

Using eclipse: 'Run As -> JUnit Tests' runs as expected, showing 1 failed test in the JUnit tab.
However: 'Run As -> Maven test' (or 'Run As -> Maven install') does not. My java test class (PropertyTests extends ClojureTest) is picked up, but no tests are found:

Running myproject.PropertyTests
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.828 sec

Results :

Tests run: 3, Failures: 0, Errors: 0, Skipped: 0

Some code, see below. I tried with and without filter, both giving the same results.

Why are the tests not picked up with maven, although they are when running the tests in eclipse with 'Run As -> JUnit Tests'?


src/test/java/myproject/PropertyTests.java:

public class PropertyTests extends ClojureTest {
    /** {@inheritDoc} */
    @Override
    public String filter() {
        return "myproject";
    }
}

src/test/clojure/myproject/gentest.clj:

(ns myproject.gentest
  (:require [clojure.test :refer :all])

(deftest fixme
  (testing "FIXME, I fail."
           (is (= 1 0))))

pom.xml:

    <depencendies>
    [...]
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.clojure</groupId>
            <artifactId>clojure</artifactId>
            <version>1.8.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>net.mikera</groupId>
            <artifactId>cljunit</artifactId>
            <version>0.4.0</version>
            <scope>test</scope>
        </dependency>
        [...]
    </dependencies>
    <build>
        <testResources>
            <testResource>
                <directory>src/test/clojure</directory>
            </testResource>
        </testResources>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <includes>
                        <include>**/*Test.java</include>
                        <include>**/*Tests.java</include>
                    </includes>
                </configuration>
            </plugin>
        </plugins>
    </build>

Open CLJUnit to work with Maven Tycho (for instance)

Hello,

I'm trying to get some clojure.test tests be executed via maven tycho surefire tests plugin phase.

That way, the tests have access to the right classpath, potentially seeing eclipse classes, etc., as provisioned via tycho (in a MANIFEST-FIRST manner).

I run SWTBot tests, and thus there's a specific JUnit runner which is somehow required: @RunWith(SWTBotJunit4ClassRunner.class)

I'm ok to find a middle-way solution, at least at first, which may involve replicating some work done inside ClojureRunner.

But I see that some classes are made package-protected, preventing me from using them (e.g. ClojureTester).

I think I'll first fork cljunit and play with some ideas, but wanted to know your position to accept pull requests for this topic?

optional message 'is'

When writing a failing test, cljunit generates an AssertionFailedError with message being a map with the expected and actual value. In the clojure 'is'-macro of clojure.test, one can provide an additional message. It would be nice to have this message added to the AssertionFailedError.

The use case I really would like to have this is: when using clojure.test.check (generative testing), the shrinker gives extremely valuable information about the reason why the assertion failed. Passing the map returned by 'tc/quick-check' as message to the is-form, would be, well... very welcome.

Can the message passed in the 'is'-macro be added to the AssertionFailedError-message, so returning a map like {:expected ... :actual ... :message ...}?

Running tests with Gradle on Windows fails with 'Invalid character in filename' error

By default, Gradle generates XML reports about all tests run, with the name being equal to test's description. Since cljunit creates a description that contains <, : and >, and all those characters are not allowed in filenames on Windows, Gradle fails.

build.gradle

buildscript {
    ext.kotlin_version = '1.0.4'
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

plugins {
    id "com.cursive-ide.clojure" version "1.1.0"
}

apply plugin: 'kotlin'
apply plugin: 'idea'
group 'cljunit-test'
version '1.0-SNAPSHOT'

repositories {
    mavenCentral()
    maven { url "https://clojars.org/repo" }
}

dependencies {
    compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    testCompile "org.clojure:clojure:1.8.0"
    testCompile "junit:junit:4.11"
    testCompile "net.mikera:cljunit:0.5.0"
    testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
}

src/test/clojure/foo.clj

(ns foo
  (:use clojure.test))

(deftest failure
  (println "Hello!")
  (is (= 2 3)))

src/test/kotlin/ClojureTests.kt

import mikera.cljunit.ClojureTest

class ClojureTests : ClojureTest () {
    override fun namespaces(): MutableList<String> {
        return mutableListOf("foo")
    }
}

output:

Testing started at 02:56 ...
02:56:42: Executing external task 'test'...
:compileKotlin UP-TO-DATE
:compileJava UP-TO-DATE
:compileClojure UP-TO-DATE
:copyMainKotlinClasses UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:compileTestKotlin
:compileTestJava UP-TO-DATE
:compileTestClojure
:copyTestKotlinClasses
:processTestResources UP-TO-DATE
:testClasses
:test
Hello!
:test FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':test'.
> Could not generate test report to 'C:\dokumenty\cljunit-test\build\reports\tests'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 11.212 secs
C:\dokumenty\cljunit-test\build\reports\tests\packages\failure  <foo.html (Nazwa pliku, nazwa katalogu lub składnia etykiety woluminu jest niepoprawna)

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.