Skip to content

Commit

Permalink
Update blog posts (robolectric#314)
Browse files Browse the repository at this point in the history
  • Loading branch information
MGaetan89 authored Sep 23, 2024
1 parent a060ba3 commit 3966714
Show file tree
Hide file tree
Showing 12 changed files with 152 additions and 135 deletions.
2 changes: 1 addition & 1 deletion docs/blog/posts/2017-03-01-hermetic-builds.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,6 @@ Gradle will download all the dependencies you need to run Robolectric and place

Add the `.jar` files listed in `build/output/README.txt` as compile-time dependencies.

Place the file called `build/output/robolectric-deps.properties` in your test resources directory. Change the paths as indicated in the comment in that file.
Place the file called `build/output/robolectric-deps.properties` in your test `resources` directory. Change the paths as indicated in the comment in that file.

You're all set! Robolectric will now load Android SDKs from the filesystem instead of attempting to download them from Maven Central.
31 changes: 19 additions & 12 deletions docs/blog/posts/2017-03-02-robolectric-3-3-and-roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,44 @@ slug: robolectric-3-3-and-roadmap

Your Robolectric maintainers are pleased to announce the release of [Robolectric 3.3](https://github.com/robolectric/robolectric/releases/tag/robolectric-3.3)! There's been a bunch of activity recently in Robolectric, and we wanted to give a quick update on our thinking about where the project is going.

### Introduction
## Introduction

Robolectric started life in 2010 as a quick hack to allow Android tests to be run on a regular JVM rather than a device or emulator, allowing for fast [TDD cycles](https://en.wikipedia.org/wiki/Test-driven_development#Test-driven_development_cycle). It was mostly developed in brief spurts as needed for testing specific projects.
Robolectric started life in 2010 as a quick hack to allow Android tests to be run on a regular JVM rather than a device or emulator, allowing for fast [TDD cycles](https://en.wikipedia.org/wiki/Test-driven_development#Coding_cycle). It was mostly developed in brief spurts as needed for testing specific projects.

Since then, it's been cool to see Robolectric grow with the help of the community, and become quite widely used. It's become a critical part of the test infrastructure of lots of companies and projects. It's rather outgrown the scrappy side-project Robolectric was for much of its life and needs some full-time attention.

Here's a high-level view of what we see as the steps ahead toward making Robolectric a trusted, well-supported and dependable Android test framework. In the coming months we’ll be working on:

### Android Fidelity and Trustworthiness
## Android Fidelity and Trustworthiness

Long ago, Robolectric lurked mostly in the shadows: there was no real Android code behind the scenes, only the bits we implemented (which we called Shadows). From 2.0 on, we've had real Android implementations available to use, but lots of old shadow implementations lingered and gave peculiar behavior, plus some bits remained unimplemented or were implemented with behavior that doesn't match that of a device. All this has left Robolectric's trustworthiness in doubt. We're working to match Android's behavior as closely as possible in the spots where we can, and to provide predictable behavior in those places where it's necessary to diverge.

### API Stability
We've had a bit of API thrash and regressions in the past and we're going to work diligently to ease the pain of staying current with robolectric releases. We'll be deprecating APIs before their removal and providing guidance on migration. We do expect a few more large and high-benefit API changes in the coming major releases, but we'll do our best to minimize their impact. We'll be careful to document changes in release notes.
## API Stability

We've had a bit of API thrash and regressions in the past, and we're going to work diligently to ease the pain of staying current with robolectric releases. We'll be deprecating APIs before their removal and providing guidance on migration. We do expect a few more large and high-benefit API changes in the coming major releases, but we'll do our best to minimize their impact. We'll be careful to document changes in release notes.

## Documentation

### Documentation
Robolectric’s documentation has always been sparse. We're aiming for clear and comprehensive documentation that reveals how the various parts of the Android SDK are simulated by Robolectric, and details extended APIs for testing.

### Performance
## Performance

Robolectric was created to make TDD super fast, so it's disappointing to us too that performance has dipped. We're going to set up a perf suite and spend some time in a profiler and try to squeeze every second out of test startup and run time.

### Toolchain Integration
## Toolchain Integration

We're working on easier project integration for several build systems, tighter integration with Android Studio, and easier and more flexible configuration in general.

### Android SDK Support
## Android SDK Support

As new SDKs and new features are released, we'll make sure Robolectric supports them quickly.

### Community
We're going to do our best to stay on top of bug reports and pull requests. We'll be continuing to develop in the open on GitHub, and we'd love your input on changes and designs.
## Community

We're going to do our best to stay on top of bug reports and pull requests. We'll be continuing to develop in the open on [GitHub](https://github.com/robolectric/robolectric), and we'd love your input on changes and designs.

As always, thanks for your pull requests, bug reports, ideas and questions!

_Your Robolectric maintainers,_
<br/>
[[email protected]](mailto:[email protected]) and [[email protected]](mailto:[email protected])
[[email protected]](mailto:[email protected]) and [[email protected]](mailto:[email protected])
12 changes: 6 additions & 6 deletions docs/blog/posts/2017-11-13-resources-for-real.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
date: 2017-11-13
authors:
- jongerrish
- brettchabot
- xian
hide:
- toc
Expand All @@ -17,11 +19,9 @@ We're doing this in three separate releases to give you a chance to fix your tes

The releases will be:

**3.6:** Resource selection based on transliterated framework code. Configuration properties set from `@Config(qualifiers=...)`.

**3.7:** Manifest parsing based on transliterated framework code.

**3.8:** Resource loading from `aapt`-processed binary resource files.
- **3.6:** Resource selection based on transliterated framework code. Configuration properties set from [`@Config(qualifiers)`](../../device-configuration.md).
- **3.7:** Manifest parsing based on transliterated framework code.
- **3.8:** Resource loading from `aapt`-processed binary resource files.

We'll keep the changes in each release focused and narrow, and provide lots of notes on migration. Stick with us through this, we think you'll be happy with the improvements.

Expand All @@ -31,4 +31,4 @@ As always, thanks for your pull requests, bug reports, ideas and questions! &#x1

_Your Robolectric maintainers,_
<br/>
[[email protected]](mailto:[email protected]), [[email protected]](mailto:[email protected]), and [[email protected]](mailto:[email protected]).
[[email protected]](mailto:[email protected]), [[email protected]](mailto:[email protected]), and [[email protected]](mailto:[email protected]).
21 changes: 12 additions & 9 deletions docs/blog/posts/2018-05-09-robolectric-4-0-alpha.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,26 @@ slug: robolectric-4-0-alpha

The Robolectric team is super excited to announce the first alpha release of Robolectric 4.0, as well as some new developments in the world of Robolectric and Android testing in general.

### `androidx.test`
We’re collaborating closely with the Android Jetpack testing team to develop common APIs for writing Android tests that can run as both local (JVM-based) and on-device (instrumentation) tests. From 4.0 on, Robolectric will support Jetpack’s [androidx.test](https://developer.android.com/training/testing/) APIs, starting with support for the [`AndroidJUnit4` test runner](https://developer.android.com/training/testing/junit-runner), [`ActivityTestRule`](https://developer.android.com/training/testing/junit-rules), and [Espresso](https://developer.android.com/training/testing/espresso/) for interacting with UI components.
## `androidx.test`

We’re collaborating closely with the Android Jetpack testing team to develop common APIs for writing Android tests that can run as both local (JVM-based) and on-device (instrumentation) tests. From 4.0 on, Robolectric will support Jetpack’s [`androidx.test`](https://developer.android.com/training/testing/) APIs, starting with support for the [`AndroidJUnit4` test runner](https://developer.android.com/training/testing/junit-runner), [`ActivityTestRule`](https://developer.android.com/training/testing/junit-rules), and [Espresso](https://developer.android.com/training/testing/espresso/) for interacting with UI components.

### A Robolectric 3.x style test

#### A Robolectric 3.x style test:
```kotlin
@RunWith(RobolectricTestRunner::class)
class RobolectricTest {
@Test fun clickingOnTitle_shouldLaunchEditAction() {
val activity = Robolectric.setupActivity(NoteListActivity::class.java)
ShadowView.clickOn(activity.findViewById(R.id.title));
ShadowView.clickOn(activity.findViewById(R.id.title))
assertThat(ShadowApplication.getInstance().peekNextStartedActivity().action)
.isEqualTo("android.intent.action.EDIT")
}
}
```

#### Robolectric 4.x/instrumentation test:
### Robolectric 4.x/instrumentation test

```kotlin
@RunWith(AndroidJUnit4::class)
class OnDeviceTest {
Expand All @@ -42,17 +45,17 @@ class OnDeviceTest {

As you can see, many of the idioms common in instrumentation tests are now supported by Robolectric tests. In the near future we'll be expanding `androidx.test` support on Robolectric, as well as introducing some Robolectric-originated testing paradigms to traditional instrumentation tests.

### Binary Resources
## Binary Resources

In conjunction with Android Studio 3.2, Robolectric can now use resources processed using the Android build toolchain, and loads and handles those resources using the same logic as on an actual Android device. Robolectric's old idiosyncratic resource handling mode is still available for projects not yet using the latest version of the build toolchain.

To enable the use of toolchain-processed resources in Robolectric tests, make sure you're using Android Gradle Plugin version `com.android.tools.build:gradle:3.2.0-alpha14` or higher, and add the following to your `gradle.properties`:
To enable the use of toolchain-processed resources in Robolectric tests, make sure you're using [Android Gradle Plugin](https://developer.android.com/studio/releases/gradle-plugin#updating-plugin) version `com.android.tools.build:gradle:3.2.0-alpha14` or higher, and add the following to your `gradle.properties`:

```properties
android.enableUnitTestBinaryResources=true
```

### Release Notes
## Release Notes

Release notes are [available here](https://github.com/robolectric/robolectric/releases/tag/robolectric-4.0-alpha-1). Robolectric 4.0 is currently in alpha release, meaning that it is not yet feature-complete, and APIs are likely to change before the final release. Use with caution.

Expand All @@ -62,4 +65,4 @@ As always, thanks for your pull requests, bug reports, ideas and questions! &#x1

_Your Robolectric maintainers,_
<br/>
[[email protected]](mailto:[email protected]), [[email protected]](mailto:[email protected]), and [[email protected]](mailto:[email protected]).
[[email protected]](mailto:[email protected]), [[email protected]](mailto:[email protected]), and [[email protected]](mailto:[email protected]).
23 changes: 13 additions & 10 deletions docs/blog/posts/2018-10-25-robolectric-4-0.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,26 @@ slug: robolectric-4-0

Robolectric 4.0 is released! Here's what's new!

### `androidx.test`
The different idioms for testing using Robolectric and instrumentation tests has long been a headache. With today's release of Robolectric 4.0 and `androidx.test` 1.0.0, both testing environments are converging on a set of common test APIs. Robolectric now supports the [`AndroidJUnit4` test runner](https://developer.android.com/training/testing/junit-runner), [`ActivityTestRule`](https://developer.android.com/training/testing/junit-rules), and [Espresso](https://developer.android.com/training/testing/espresso/) for interacting with UI components.
## `androidx.test`

The different idioms for testing using Robolectric and instrumentation tests have long been a headache. With today's release of Robolectric 4.0 and [`androidx.test`](https://developer.android.com/training/testing/) 1.0.0, both testing environments are converging on a set of common test APIs. Robolectric now supports the [`AndroidJUnit4` test runner](https://developer.android.com/training/testing/junit-runner), [`ActivityTestRule`](https://developer.android.com/training/testing/junit-rules), and [Espresso](https://developer.android.com/training/testing/espresso/) for interacting with UI components.

### A Robolectric 3.x style test

#### A Robolectric 3.x style test:
```kotlin
@RunWith(RobolectricTestRunner::class)
class RobolectricTest {
@Test fun clickingOnTitle_shouldLaunchEditAction() {
val activity = Robolectric.setupActivity(NoteListActivity::class.java)
ShadowView.clickOn(activity.findViewById(R.id.title));
ShadowView.clickOn(activity.findViewById(R.id.title))
assertThat(ShadowApplication.getInstance().peekNextStartedActivity().action)
.isEqualTo("android.intent.action.EDIT")
}
}
```

#### Robolectric 4.x/instrumentation test:
### Robolectric 4.x/instrumentation test

```kotlin
@RunWith(AndroidJUnit4::class)
class OnDeviceTest {
Expand All @@ -42,7 +45,7 @@ class OnDeviceTest {

As you can see, many of the idioms common in instrumentation tests are now supported by Robolectric tests. In future releases we'll be expanding `androidx.test` support on Robolectric, as well as introducing some Robolectric-originated testing paradigms to traditional instrumentation tests.

### Binary Resources
## Binary Resources

In conjunction with Android Studio 3.2, Robolectric can now use resources processed using the Android build toolchain, and loads and handles those resources using the same logic as on an actual Android device. Robolectric's old idiosyncratic resource handling mode is still available for projects not yet using the latest version of the build toolchain, but is now deprecated and will be removed in a future release.

Expand All @@ -68,11 +71,11 @@ Add this line to your `gradle.properties` (no longer necessary with Android Stud
android.enableUnitTestBinaryResources=true
```

### Migration Tool
## Migration Tool

Robolectric 4.0 contains a number of API changes that may require modifications to your test code. Check out the [migration notes](../../migrating.md/#migrating-to-40) and use the new [automated migration tool](../../automated-migration.md) to help convert your existing tests to be compatible with Robolectric 4.0.
Robolectric 4.0 contains a number of API changes that may require modifications to your test code. Check out the [migration notes](../../migrating.md#migrating-to-40) and use the new [automated migration tool](../../automated-migration.md) to help convert your existing tests to be compatible with Robolectric 4.0.

### Release Notes
## Release Notes

Release notes are [available here](https://github.com/robolectric/robolectric/releases/tag/robolectric-4.0).

Expand All @@ -82,4 +85,4 @@ As always, thanks for your pull requests, bug reports, ideas and questions! &#x1

_Your Robolectric maintainers,_
<br/>
[[email protected]](mailto:[email protected]), [[email protected]](mailto:[email protected]), and [[email protected]](mailto:[email protected]).
[[email protected]](mailto:[email protected]), [[email protected]](mailto:[email protected]), and [[email protected]](mailto:[email protected]).
Loading

0 comments on commit 3966714

Please sign in to comment.