Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7161987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:39:37+00:00 2026-05-28T13:39:37+00:00

I am attempting to write some JUnit tests for my android application. The application

  • 0

I am attempting to write some JUnit tests for my android application. The application is a service.

I have tried several things to get the ServiceTestCase to launch the service but it fails to.

HOWEVER, when i debug the ServiceTestCase it WILL launch the service. I belive this is because the ServiceTestCase is calling setup and not giving enough time for the service to launch before it kills it…

I am not completely sure, this is the first time i have ever used junit testing for android. VERY new to this. Any suggestions on what i can do to fix this problem?

I was thinking of creating some timer loop or something, but that seems REALLY dirty. Would like a much cleaner aproach.


Android Manifest for the service.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="dataservice.server"
    <uses-sdk android:minSdkVersion="10" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WAKE_LOCK"></uses-permission>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"></uses-permission>
    <uses-permission android:name="android.permission.INTERNET"></uses-permission>
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <service android:name="dataservice.server.DataServer"  android:process=":remote" android:exported="true" android:enabled="true">
            <intent-filter>
                <action android:name="dataservice.DataService.BIND.1" />
            </intent-filter>
            <intent-filter>
                <action android:name= ".DataServer" />
            </intent-filter>
        </service>
        <receiver android:name="dataservice.server.Receiver">
            <intent-filter>
                <action android:name="android.intent.action.USER_PRESENT"></action>
                <action android:name="android.intent.action.BOOT_COMPLETED"></action>
            </intent-filter>
        </receiver>
    </application>
</manifest>

The ServiceTestCase i am attempting.
public class Publish extends ServiceTestCase<DataServer> {

    private final static String TAG = "Publish Unit Test";
    private Context mSystemContext;

    public Publish() {
        super(DataServer.class);
    }

    public Publish(Class<DataServer> serviceClass) {
        super(serviceClass);
    }

    @Override
    protected void setUp() throws Exception {
        // TODO Auto-generated method stub
        super.setUp();
                // this is where i am attempting to start the service.
                // i have attempted other methods, but none of those worked either.
                startService(new Intent(this.getContext(), DataServer.class));
    }

    public void testPublish() {
      }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T13:39:37+00:00Added an answer on May 28, 2026 at 1:39 pm

    I was referencing one of the dependant projects incorrectly. Once this was fixed, it resolved the issue. So, check and make sure you are referencing your projects correctly if you are having the same issue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to write some tests using the built-in android Junit testing framework. I
I'm attempting to write some unit tests using EasyMock and TestNG and have run
I have been attempting to write some routines to read RSS and ATOM feeds
I am attempting to write some tests using webtest to test out my python
Morning Everyone, I've been attempting to write an application that does some GETs from
I am attempting to write some simple code in F#, and i get this
I am trying to write some application tests for my app based on the
I am attempting to write some Tests for a small project of mine but
I'm attempting to write a mod_rewrite rule to remap some friendly URLs for searches,
I am attempting to write an application that uses libCurl to post soap requests

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.