question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Test code cannot access internal functions in same module

See original GitHub issue

While trying to upgrade to Dagger 2.31.2 I noticed that some of my tests failed to compile saying that the functions they were testing were not accessible because they are internal. After some experimentation I concluded that enableExperimentalClasspathAggregation was the culprit. If I enable it my tests fail to compile, if I leave it disabled they compile just fine.

I’m assuming this has something to do with how that is implemented and I’m guessing it tweaks kapt or something like that.

The module in question is an android library module and I’m using the following dagger/kapt options:

kapt {
  useBuildCache = true
  correctErrorTypes = true

  arguments {
    arg("dagger.fastInit", "enabled")
    arg("dagger.validateTransitiveComponentDependencies", "DISABLED")
  }
}

hilt {
  enableExperimentalClasspathAggregation = true
}

android {
  lintOptions.isCheckReleaseBuilds = false
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ansmancommented, Feb 8, 2021

I can confirm it’s working using a snapshot build off master 👏

1reaction
sergeys-operacommented, Feb 8, 2021

I face the same issue with enableExperimentalClasspathAggregation = true. It also breaks :app:lintRelease:

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:lintRelease'.
> Could not resolve all files for configuration ':app:debugUnitTestRuntimeClasspath'.
Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to Access Internal Classes from Test Code within ...
Unable to Access Internal Classes from Test Code within Same Module If I have an internal class defined like this in my main...
Read more >
How to access and test an internal (non-exports) function in a ...
The rewire module is definitely the answer. Here's my code for accessing an unexported function and testing it using Mocha. application.js:
Read more >
Unit Testing Module-Internal Functions
Unit tests are supposed to be for external functions only. Nevertheless, if you have a lot of "internal code", it should be tested...
Read more >
Can't access internal functions from test module - JavaScript
Hi there,. Say that I have 2 files: ... I expected this to work, because both functions are defined in the same package....
Read more >
2. Maintainability depends on modularity: Stop using ...
Modular code is code which is separated into independent modules. ... to the other module directly via a global name; it might use...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found