I have a test project in VS 2019 with Specflow.
I updated to Specflow 3.4.3.
I want to use MsTest as test provider, therefore I have installed the Specflow.MsTest nuget package.
Building the project works, but when I try to execute one of the tests in the project with vstestconsole via the command line by using the built .dll on one of my test machines, I am getting the following error:
MSTestAssemblyHooks.AssemblyInitialize threw exception. BoDi.ObjectContainerException: BoDi.ObjectContainerException: Interface cannot be resolved: TechTalk.SpecFlow.UnitTestProvider.IUnitTestRuntimeProvider('nunit'). Aborting test execution.
Stack Trace:
at BoDi.ObjectContainer.TypeRegistration.Resolve(ObjectContainer container, RegistrationKey keyToResolve, ResolutionList resolutionPath)
at BoDi.ObjectContainer.ResolveObject(RegistrationKey keyToResolve, ResolutionList resolutionPath)
at BoDi.ObjectContainer.Resolve(Type typeToResolve, ResolutionList resolutionPath, String name)
at BoDi.ObjectContainer.Resolve[T](String name)
at TechTalk.SpecFlow.Infrastructure.ContainerBuilder.CreateGlobalContainer(Assembly testAssembly, IRuntimeConfigurationProvider configurationProvider)
at TechTalk.SpecFlow.TestRunnerManager.CreateTestRunnerManager(Assembly testAssembly, IContainerBuilder containerBuilder)
at TechTalk.SpecFlow.TestRunnerManager.GetTestRunnerManager(Assembly testAssembly, IContainerBuilder containerBuilder, Boolean createIfMissing)
at TechTalk.SpecFlow.TestRunnerManager.OnTestRunStart(Assembly testAssembly, IContainerBuilder containerBuilder)
Does anybody know how to resolve that issue?
Related
I want to compile the ANTLR4 Java distribution using Maven. But it won't work.
I am probably going about this problem wrongly. There may be something very simple I am missing. Probably the way I'm calling Maven in the first place. The fact that absolutely no-one on the Internet seems to have this problem indicates as much.
What happens
First, my Java version:
$ java -version
openjdk version "17.0.3" 2022-04-19
OpenJDK Runtime Environment Temurin-17.0.3+7 (build 17.0.3+7)
OpenJDK 64-Bit Server VM Temurin-17.0.3+7 (build 17.0.3+7, mixed mode, sharing)
(But note that ANLTR4 is compiled to Java 11, except for the plugin which is compiled to Java 8, according to the POM)
So. Get the distribution from github:
$ git clone https://github.com/antlr/antlr4.git antlr4_30`
$ cd antlr4_30
$ git status
On branch master
Your branch is up to date with 'origin/master'.
Compile the projects (Maven modules)
runtime/Java (the ANTLR4 core classes)
tool (the ANTLR4 compiler)
antlr4-maven-plugin (the maven plugin that runs ANTLR4 tasks)
PROJECTS="runtime/Java,tool,antlr4-maven-plugin"
mvn --projects "$PROJECTS" clean
mvn --projects "$PROJECTS" verify
Compilation works, then the tests for the maven plugin kick off.
These tests are run using another maven plugin by "Takari" for plugin unit testing: Plugin Unit Testing.
The ANTLR4 Maven plugin tests fail:
java.lang.NullPointerException: Cannot invoke
"org.apache.maven.model.Plugin.getGroupId()"
because the return value of
"org.apache.maven.plugin.MojoExecution.getPlugin()"
is null
with the interesting part of the stack trace:
org.apache.maven.lifecycle.internal.
DefaultMojoExecutionConfigurator.configure(DefaultMojoExecutionConfigurator.java:44)
(called by) io.takari.maven.testing.
Maven331Runtime.lookupConfiguredMojo(Maven331Runtime.java:37)
(called by) io.takari.maven.testing.
Maven325Runtime.executeMojo(Maven325Runtime.java:34)
(called by) io.takari.maven.testing.
TestMavenRuntime.executeMojo(TestMavenRuntime.java:269)
(called by) org.antlr.mojo.antlr4.
Antlr4MojoTest.processWhenDependencyRemoved(Antlr4MojoTest.java:326)
So what's going on?
After a lengthy trawl through the source code (code which is not straightforward to read but unfortunately lacks comments, logging or assertions, these would be useful), we find:
In class org.antlr.mojo.antlr4.Antlr4MojoTest (file antlr4-maven-plugin/src/test/java/org/antlr/mojo/antlr4/Antlr4MojoTest.java), the failing test cases perform the following (example of test case processWhenDependencyRemoved(), slightly modified & commented):
// Junit4 rule
#Rule
public final TestMavenRuntime maven = new TestMavenRuntime();
#Test
public void processWhenDependencyRemoved() throws Exception {
Path baseDir = resources.getBasedir("dependencyRemoved").toPath();
Path antlrDir = baseDir.resolve("src/main/antlr4");
Path baseGrammar = antlrDir.resolve("imports/HelloBase.g4");
MavenProject project = maven.readMavenProject(baseDir.toFile());
MavenSession session = maven.newMavenSession(project);
String goal = "antlr4";
// Get a "org.apache.maven.plugin.MojoExecution" from the
// "io.takari.maven.testing.TestMavenRuntime" instance.
assertTrue(maven instanceof io.takari.maven.testing.TestMavenRuntime);
MojoExecution exec = maven.newMojoExecution(goal);
maven.executeMojo(session, project, exec);
...
Now, org.apache.maven.plugin.MojoExecution (the exec instance) provides a .getPlugin() method which returns null instead of a valid instance of org.apache.maven.model.Plugin (a class generated by Modello when Maven itself is compiled).
After two stack frames, org.apache.maven.lifecycle.internal.DefaultMojoExecutionConfigurator.configure() is called, but then fails immediately in a chained call:
public void configure( MavenProject project, MojoExecution mojoExecution, boolean allowPluginLevelConfig )
{
String g = mojoExecution.getPlugin().getGroupId();
String a = mojoExecution.getPlugin().getArtifactId();
Plugin plugin = findPlugin( g, a, project.getBuildPlugins() );
...
Why does getPlugin() return null? From maven's org.apache.maven.plugin.MojoExecution, file core/maven-3/maven-core/src/main/java/org/apache/maven/plugin/MojoExecution.java:
public Plugin getPlugin()
{
if ( mojoDescriptor != null )
{
return mojoDescriptor.getPluginDescriptor().getPlugin();
}
return plugin;
}
I our case, mojoDescriptor is not null, but mojoDescriptor.getPluginDescriptor().getPlugin() is, which is bad.
I have no idea why the Plugin instance is not set, or even where it is supposed to be set.
At some point, Maven's org.apache.maven.plugin.descriptor.PluginDescriptorBuilder is called from Takari's io.takari.maven.testing.Maven30xRuntime (source) to build org.apache.maven.plugin.descriptor.PluginDescriptor from the plugin.xml resource and that works nicely but the plugin member is not set at that time. The data structures are not straightforward. Below, for what it's worth, the relationship between a few of the classes.
It looks like the "correct" way to build ANTLR4 from the repo is:
$ export MAVEN_OPTS="-Xmx1G" # don't forget this on linux
cd /tmp/antlr4 # or wherever you have the software
rm -rf ~/.m2/repository/org/antlr*
mvn clean
mvn -DskipTests install
see here for explanation.
This worked for me.
I'm trying to configure the Test task inside a custom Gradle plugin written in Java.
Applying the plugins I need like so in build.gradle.kts:
plugins {
`java-gradle-plugin`
`maven-publish`
}
I can compile the code successfully through the command line as in ./gradlew clean build
But, IntelliJ complains about Test.class in the following code:
public static void configureTesting(final Project project) {
project.getTasks().withType(Test.class).configureEach(task -> {
});
}
Saying:
Required type: java.lang.Class <S>
Provided: java.lang.Class <Test>
reason: no instance(s) of type variable(s) exist so that T conforms to Task
I import the Test class like this:
import org.gradle.api.tasks.testing.Test;
Gradle version: 6.7.1
IntelliJ: 2020.2.3
I spent some (a lot of) time googling this. Eventually I found a comment somewhere saying that one could try to use the internal SDK (jbr) that ships with IntelliJ instead of a manually downloaded SDK. That made it work. The internal SDK is Java 11 and I've also installed the latest version of Java 11 from Oracle. Even though they are both Java 11, the internal SDK (jbr) is working as it should, but not the external SDK. For other projects the external SDK is working fine, but not for building a Gradle plugin.
I am trying to generate a .apk file of my react native project with the 'gradlew assembleRelease' command. I'm using AWS Amplify, which is where the naming collision seems to be coming from. The version of react native I'm running is 0.59.9.
I've tried creating a 'rn-cli.config.js' file in the root folder and replacing the code in the 'metro.config.js' with the 'rn-cli.config.js' code, which was unsuccessful. I can't remove the problem folder either because that creates more errors.
I've also tried stopping and restarting the Gradle daemon, which hasn't worked either. This is the error I'm getting:
Configure project :app
WARNING: The specified Android SDK Build Tools version (25.0.0) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle Plugin 3.4.0.
Android SDK Build Tools 28.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '25.0.0'" from your build.gradle file, as each version of the Android Gradle Plugin now has a
default version of the build tools.
Task :app:bundleReleaseJsAndAssets
warning: the transform cache was reset.
error jest-haste-map: Haste module naming collision:
Duplicate module name: myreactnativeapp_cfnlambda_ff57ce62
Paths: C:\Users\Kim\Desktop\myReactNativeApp\amplify\backend\interactions\reactLex\src\package.json collides with C:\Users\Kim\Desktop\myReactNativeApp\amplify#current-cloud-backend\interactions\reactLex\src\package.json
This error is caused by hasteImpl returning the same name for different files.. Run CLI with --verbose flag for more details.
Task :app:bundleReleaseJsAndAssets FAILED
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:bundleReleaseJsAndAssets'.
Process 'command 'cmd'' finished with non-zero exit value 1
The code in the 'rn-cli.config.js' file looks like this:
const blacklist = require('metro-config/src/defaults/blacklist');
// blacklist is a function that takes an array of regexes and combines
// them with the default blacklist to return a single regex.
module.exports = {
resolver: {
blacklistRE: blacklist([/amplify\/.*/])
}
};'
Do I need to change the code in the 'rn-cli.config.js' file or is there another workaround I could try?
I am facing some issue while building spring-framework source, what is the issue?
FAILURE: Build failed with an exception.
Where:
Build file '/home/steph/workspace_sts/spring-framework/spring-beans/spring-beans.gradle' line: 30
What went wrong:
A problem occurred evaluating project ':spring-beans'.
> No such property: values for class: org.gradle.api.internal.tasks.DefaultTaskDependency
Possible solutions: values
It seems to be saying that the class DefaultTaskDependency does not have a field and getter/setter called getValues()/setValues() but the gradle build file is passing in some data which it is trying to set by calling setValues() and passing whatever data is in the gradle.build file under values. I would double check which version of gradle spring source says it needs to be built with vs. what version you are building it with.
I have gradle project which has lombok jar ,i have added the below dependency in gradle, Gradle version : 4.5.1
compileOnly group:'org.projectlombok',name:'lombok', version: '1.16.20'
gradle build in command prompts not working
For me the expression you referenced is working correctly. Can you provide more detailed description of the error you observed. To display more detailed trace on what went wrong use the '--stacktrace' command line switch, for example:
.\gradlew --stacktrace assemble
Is the command line gradle gives you the compile error message? Or are you using Android Studio if so perhaps you forgot to setup lombok as a annotation Processor agent, see: https://projectlombok.org/setup/android and File > Other Settings > Default Settings... > Build, Execution, Development > Compiler > Annotation Processors > Enable annotation processing.
Finally Able to resolve the issue :) The spring rest api is like public Department getEmployeesDepartmet(#Pathvariabel(ID) int id , #Pathvariable(employeId)int employeeID)
here ID and employeeID was string constant due to this getting compiler error int cannot convert to String just removed the constant and added string variables in path variable –