Coder Social home page Coder Social logo

Android support about gradle-pitest-plugin HOT 30 CLOSED

szpak avatar szpak commented on June 12, 2024 14
Android support

from gradle-pitest-plugin.

Comments (30)

szpak avatar szpak commented on June 12, 2024 24

Thanks for the information. I suspect that it also uses JavaBasePlugin instead of JavaPlugin which is not very feasible to support both in the same code base. Nevertheless it is not hopeless, so I will probably give it a shot (one day). Votes from other Android developers willing to use PIT in their project could make that day sooner :).

from gradle-pitest-plugin.

koral-- avatar koral-- commented on June 12, 2024 3

Sorry, I just enabled isssues and created one: https://github.com/koral--/gradle-pitest-plugin/issues/1
I'll check that.

UPDATE:
Issue reported by @FloKaemmerer was caused by missing RobolectricTestRunner in test. Tests using Android platform APIs may not work without it.

UPDATE 2:
Just released version 0.0.7 does not require robolectric nor any tests source code changes like adding runners. More info in README.

from gradle-pitest-plugin.

szpak avatar szpak commented on June 12, 2024 1

@Shyish You can use an Android for provided by @koral-- - https://github.com/koral--/gradle-pitest-plugin . It seems to work and as the changes there are quite heavy (and incompatible) I'm not very eager to backport them to the vanilla JVM version.

from gradle-pitest-plugin.

szpak avatar szpak commented on June 12, 2024 1

The FAQ is in the README :)

from gradle-pitest-plugin.

szpak avatar szpak commented on June 12, 2024

It's the same issue as #24. Do you also use robolectric-gradle-plugin or something else?

Update 2016

There is a @koral--'s version of that plugin for Android. It seems to work fine and it is recommended for Android-based projects.

See: https://github.com/koral--/gradle-pitest-plugin

from gradle-pitest-plugin.

vanniktech avatar vanniktech commented on June 12, 2024

You don't need that plugin anymore. At least it's no longer mandatory. Google guys have recently launched Java Unit Tests for Android projects, so that can be used. So you only need to include the dependency testCompile 'org.robolectric:robolectric:3.0'.

From the command line you can ./gradlew clean test for executing the tests. The task itself is however named test<Module+Flavor>UnitTest

from gradle-pitest-plugin.

emartynov avatar emartynov commented on June 12, 2024

Also interested to try

from gradle-pitest-plugin.

mdhornet90 avatar mdhornet90 commented on June 12, 2024

Definitely interested.

from gradle-pitest-plugin.

gdaolewe avatar gdaolewe commented on June 12, 2024

Also interested, mutation testing is a great concept that issues like this have always kept me from using in any project.

from gradle-pitest-plugin.

JosephYao avatar JosephYao commented on June 12, 2024

Definitely interested.

from gradle-pitest-plugin.

 avatar commented on June 12, 2024

Very interested

from gradle-pitest-plugin.

Endran avatar Endran commented on June 12, 2024

Me as well!

from gradle-pitest-plugin.

vanniktech avatar vanniktech commented on June 12, 2024

@szpak what's the state of this, since the creation of this issue quite a few others are interested in this

from gradle-pitest-plugin.

szpak avatar szpak commented on June 12, 2024

I'm not an Android developer. Is this the only recommended way of testing that would be good to be supported?

from gradle-pitest-plugin.

 avatar commented on June 12, 2024

@szpak The document you linked appears to be very old. Look here for more up to date references about testing in Android

from gradle-pitest-plugin.

xgouchet avatar xgouchet commented on June 12, 2024

Really interested about this as well !

from gradle-pitest-plugin.

szpak avatar szpak commented on June 12, 2024

I cannot declare when I will be able to take a look at the possibility of implementation that. However, if someone provided a really small/minimal example of the Android application with a test which can be mutated I could use it as an acceptance test (that sunny day).
It would be good to make it possible to run unit tests from Travis, preferable without Android SDK downloaded and installed.

from gradle-pitest-plugin.

emartynov avatar emartynov commented on June 12, 2024

Here is my pet project that has some test in it https://github.com/emartynov/android-template-project. It also runs on Travis.

I also tried to quickly make it working for android https://github.com/emartynov/gradle-pitest-plugin, but should spend more time on it. The problem is that Android plugin can not be used together with Java, but it is actually extending it. Another problem that sources sets are empty at moment plugin applications. And if I'm correct they will be available after evaluation

from gradle-pitest-plugin.

szpak avatar szpak commented on June 12, 2024

Yup. I had similar observations and because of that I'm not if it will be possible/feasible to have just one plugin class for Java apps and Android apps. However, it was just a brief look.

Thanks @emartynov for the project.

from gradle-pitest-plugin.

szpak avatar szpak commented on June 12, 2024

Btw, @emartynov This project requires Android SDK which can be problematic (long running) to use on Travis. As I read the aforementioned documentation for unit testing:

Local unit tests are tests that run on your local machine, without needing access to the Android framework or an Android device.

This page also does not mention Android SDK - just mocking Android dependencies.

Is it possible to run unit tests without Android SDK?

from gradle-pitest-plugin.

mdhornet90 avatar mdhornet90 commented on June 12, 2024

I thought that the primary benefit of Robolectric was that it ran Android code on the JVM. If that's 100% the case, it should absolutely be possible.

from gradle-pitest-plugin.

emartynov avatar emartynov commented on June 12, 2024

@szpak we treat Android SDK as JDK, which you have to download and install once.
After your unit tests should be runnable offline as you expect.

And yes, Robolectric is there to run all tests on JVM, so no needs to create/run emulator or have connected android device

from gradle-pitest-plugin.

koral-- avatar koral-- commented on June 12, 2024

@emartynov was correct (#31 (comment)) - required data is available after project evaluation.
Additionally it seems that pitest plugin must either apply android plugin (but it doesn't know which one - application, library or test) or be applied after android plugin (like eg. android-apt does).
Here is my try: https://github.com/koral--/gradle-pitest-plugin

There are some issues with tests using particular classes (eg. org.robolectric.annotation.Config) but simple examples (like those from functional tests) seems to work.

UPDATE:
I've managed to fix that issue.

from gradle-pitest-plugin.

aballano avatar aballano commented on June 12, 2024

Any updates on this? Would be really nice to have this working on Android.

from gradle-pitest-plugin.

FloKaemmerer avatar FloKaemmerer commented on June 12, 2024

@koral-- I tried using your plugin on an Android project, but I'm not able to get it to work.

I striped down my project to a simple example: https://github.com/FloKaemmerer/PiProblem
Running the testsuit runs green, no matter if I'm using Androidstudio or gradle.

But when I try to use the pitest task, the test fails.

Any tips would be appreciated.

from gradle-pitest-plugin.

aballano avatar aballano commented on June 12, 2024

@FloKaemmerer I have the same issue at the moment. I think we should translate this conversation to that repo so we don't spam this one, could you please create the issue there?

from gradle-pitest-plugin.

FloKaemmerer avatar FloKaemmerer commented on June 12, 2024

@Shyish I would have opened an issue over there, but @koral-- didn't enable it :-/

from gradle-pitest-plugin.

vanniktech avatar vanniktech commented on June 12, 2024

Since there seems to be a successor / fork I'll close this.

from gradle-pitest-plugin.

szpak avatar szpak commented on June 12, 2024

I would name is an Android version of that plugin. It cannot be used with the "normal" Java projects.

There is a point in the FAQ, so I hope people will be able to find it even having that issue closed.

from gradle-pitest-plugin.

vanniktech avatar vanniktech commented on June 12, 2024

Oh okay got it. Maybe also mention the Android Version in the README.

from gradle-pitest-plugin.

Related Issues (20)

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.