Giter Site home page Giter Site logo

lint-junit-rule's People

Contributors

a11n avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

lint-junit-rule's Issues

Add sample

Showcase usage of this rule.
Emphasize standard approach vs. JUnit4 approach.

Could not resolve v0.3.0

In our project, it's fail to resolve this library from jcenter

Here is the gradle script

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:$GRADLE_PLUGIN_VERSION"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$KOTLIN_PLUGIN_VERSION"
        classpath "com.neenbedankt.gradle.plugins:android-apt:$APT_PLUGIN_VERSION"
        classpath "com.novoda:bintray-release:$BINTRAY_PLUGIN_VERSION"
        classpath "com.netflix.nebula:gradle-extra-configurations-plugin:$CONFIG_PLUGIN_VERSION"
    }
}

allprojects {
    repositories {
        jcenter()
    }
}
apply plugin: 'java'

targetCompatibility = JavaVersion.VERSION_1_7
sourceCompatibility = JavaVersion.VERSION_1_7

configurations {
    lintChecks
}

dependencies {
    compile "com.android.tools.lint:lint-api:$LINT_VERSION"
    compile "com.android.tools.lint:lint-checks:$LINT_VERSION"

    testCompile "junit:junit:$JUNIT_VERSION"
    testCompile "com.android.tools.lint:lint:$LINT_VERSION"
    testCompile "com.android.tools.lint:lint-tests:$LINT_VERSION"
    testCompile "com.android.tools:testutils:$LINT_VERSION"

    testCompile "de.ad:lint-junit-rule:0.3.0"
    testCompile 'de.ad:lint-assertj:0.3.0'
    testCompile 'de.ad:lint-hamcrest:0.3.0'

    lintChecks files(jar)
}

jar {
    manifest {
        attributes("Lint-Registry": "permissions.dispatcher.PermissionDispatcherIssueRegistry")
    }
}

Error message

* What went wrong:
Could not resolve all dependencies for configuration ':lint:testCompile'.
> Could not find de.ad:lint-junit-rule:0.3.0.
  Searched in the following locations:
      https://jcenter.bintray.com/de/ad/lint-junit-rule/0.3.0/lint-junit-rule-0.3.0.pom
      https://jcenter.bintray.com/de/ad/lint-junit-rule/0.3.0/lint-junit-rule-0.3.0.jar
  Required by:
      PermissionsDispatcher:lint:unspecified
> Could not find de.ad:lint-assertj:0.3.0.
  Searched in the following locations:
      https://jcenter.bintray.com/de/ad/lint-assertj/0.3.0/lint-assertj-0.3.0.pom
      https://jcenter.bintray.com/de/ad/lint-assertj/0.3.0/lint-assertj-0.3.0.jar
  Required by:
      PermissionsDispatcher:lint:unspecified
> Could not find de.ad:lint-hamcrest:0.3.0.
  Searched in the following locations:
      https://jcenter.bintray.com/de/ad/lint-hamcrest/0.3.0/lint-hamcrest-0.3.0.pom
      https://jcenter.bintray.com/de/ad/lint-hamcrest/0.3.0/lint-hamcrest-0.3.0.jar
  Required by:
      PermissionsDispatcher:lint:unspecified

There seems no jars in jcenter. Check this https://jcenter.bintray.com/de/ad/

Could you upload jar file? or am I missing something?

Thanks in advance.

Add inline declaration of test resources

The standard LintDetectorTest features two approaches to load test resources:

  • lintFiles and
  • lintProject

While the first approach is already covered by lint-junit-rule it would be convenient to also feature the second approach in order to allow inline declaration of test resources.

Sample test cases for .java file?

Could you give me a sample test case for .java file?

@RunWith(JUnit4.class)
public class LintTestCase extends TestCase {

    @Rule
    public Lint lint = new Lint(new PermissionDispatcherDetector(), PermissionDispatcherDetector.ISSUE);

    @Test
    public void testFoo() throws Exception {
        List<Warning> lintResult = lint.files("MainActivity.java");
        assertThat(lintResult).hasWarnings(1).in("MainActivity.java");
    }
}

This code does not work since it claims there is no MainActivity.java, so changed it to

@RunWith(JUnit4.class)
public class LintTestCase extends TestCase {

    @Rule
    public Lint lint = new Lint(new PermissionDispatcherDetector(), PermissionDispatcherDetector.ISSUE);

    @Test
    public void testFoo() throws Exception {
-        List<Warning> lintResult = lint.files("MainActivity.java");
+        List<Warning> lintResult = lint.files("MainActivity.class");
        assertThat(lintResult).hasWarnings(1).in("MainActivity.java");
    }
}

And now it run the test case. However, I want to test the lint for MainActivity.java not MainActivity.class because .java file contains annotations with @Retention(RetentionPolicy.SOURCE) which is deleted in .class in compile time.

Thanks in advance.

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.