@Test
public void testStartRecording()throws NoSuchFieldException, IllegalAccessException,InterruptedException{

    PauseResumeAudioRecorder pauseResumeAudioRecorder=new PauseResumeAudioRecorder();
    pauseResumeAudioRecorder.setAudioFile(Environment.getExternalStorageDirectory() + "/recording.wav");
    pauseResumeAudioRecorder.setChannel(AudioFormat.CHANNEL_IN_STEREO);
    pauseResumeAudioRecorder.setSampleRate(44100);
    pauseResumeAudioRecorder.setAudioEncoding(AudioFormat.ENCODING_PCM_8BIT);
    pauseResumeAudioRecorder.startRecording();
    Assert.assertNotNull("Recording thread is not created", currentAudioRecordingThreadField.get(pauseResumeAudioRecorder));
    Assert.assertEquals("Correct state not set", PauseResumeAudioRecorder.RECORDING_STATE, pauseResumeAudioRecorder.getCurrentState());
    Assert.assertNotNull("Timer is null", onTimeCompletedTimerField.get(pauseResumeAudioRecorder));
    Assert.assertNotNull("TimerTask is null",onTimeCompletionTimerTaskField.get(pauseResumeAudioRecorder));
    Assert.assertTrue("start time not set",((long)recordingStartTimeMillisField.get(pauseResumeAudioRecorder))>=0);
    Thread.sleep(100);//Give it some time to create the file.
    //Thread's fields
    audioRecordThreadField=currentAudioRecordingThreadField.get(pauseResumeAudioRecorder).getClass().getDeclaredField("currentAudioRecording");
    audioRecordThreadField.setAccessible(true);
    AudioRecord audioRecord=(AudioRecord)audioRecordThreadField.get(currentAudioRecordingThreadField.get(pauseResumeAudioRecorder));
    ShadowAudioRecord shadowAudioRecord=Robolectric.shadowOf_(audioRecord);
    Assert.assertTrue("AudioRecord is not recording", shadowAudioRecord.isRecording);
    Assert.assertEquals("AudioRecord has wrong sample rate", 44100, shadowAudioRecord.sampleRateInHz);
    Assert.assertEquals("AudioRecord has wrong audio encoding", AudioFormat.ENCODING_PCM_8BIT, shadowAudioRecord.audioFormat);
    Assert.assertEquals("AudioRecord has wrong audio source", MediaRecorder.AudioSource.MIC,shadowAudioRecord.audioSource);
    Assert.assertEquals("AudioRecord has wrong channel config", AudioFormat.CHANNEL_IN_STEREO, shadowAudioRecord.channelConfig);
    final File pcmFile=new File(Environment.getExternalStorageDirectory() + "/recording.temp");
    Assert.assertTrue(pcmFile.exists());
    pcmFile.delete();
}