How can I discover tests from packages in another module on a Java project using Junit LauncherDiscoveryRequest? - junit

I tried to check for answers in https://junit.org/junit5/docs/current/user-guide/#advanced-topics.
The code works fine for package selection if we want to disocver in same package or down package but it is unable to search for tests if the tests are present in some other package in other module.
Code -->
LauncherDiscoveryRequestBuilder.request()
.selectors(
selectPackage("com")
)
.filters(
TagFilter.includeTags(tag)
)
.configurationParameters(map).build();

Use Classdir and selectClasspathRoots(Collections.singleton(Paths.get(classdir.toURI()))) method to pass in selectors to discover tests in entire directory. If tests are present in other module , they will be discovered too.
Use below for Classdir
File classdir = new File("Project Path\ProjectName\target\*");
All the tests present in target folder will be discovered.

Related

Angular Storybook cypress tests failing on Azure pipelines during build

I have a libs component project. Recently we updated to Angular 14 to Angular 15
Locally when i run npm run storybook:cypress - all works fine and tests have passed.
But when the tests are run on Azure on pull request - they fail with next error:
The injectable 'PlatformLocation' needs to be compiled using the JIT compiler, but '#angular/compiler' is not available.
And i totally have no idea what is wrong, all similar information in the Web is related to updating Angurlar to 13 version.
What i'm trying to say, if the configs were wrong, then it would fail already on Angular 14. Where i should start digging?
I have tried:
removing angularCompilerOptions from TSconfig.lib.json ( prod also )
adding compilationMode = full instead of current partial from TSconfig.lib.json ( prod also )
checked that test-setup.ts imports 'jset-preset-angular/setup-jest' instead of simple setip-jest
I have checked that PlatformLocation is not used somewhere incorrectly, e.g. imports component instead of module ( but my code doesn't use that at all )
Project structure is next:
apps
--myproject-e2e
----src
----cypress.json
----tsconfig.json
libs
--myproject
----src
----package.json
----tsconfig.json
----tsconfig.lib.json
----tsconfig.lib.prod.json
package.json
angular.json
jest.config.json
jest.preset.json
tsconfig.json
tsconfig.base.json

Create React App Rewired application ignoring jest.config.js

I have a react application created using "create react app rewired". I've installed ts-jest and want to be able to customize Jest. I read the documentation from ts-jest and executed npx ts-jest config:init at the root level of my project to create the initial configuration file. To test that jest is indeed using that configuration file, I wrote the following line console.log(window); in a sample test file and modified the configuration such that testEnvironment is set to "node".
I am expecting the test to fail due to window being undefined, but I am getting the window object back. I tried renaming the file to jest.config.ts and I got the same result.
I did a global search across all the files to see if there's another configuration file somewhere that is overriding my configurations, but there was none found.
What am I doing wrong? I know jest comes pre-packaged with create-react-app (CRA). I would imagine that create-react-app-rewired would only include some wrapper above CRA so where is it getting its configurations from?
I've come to realize that create-react-app-rewired package had nothing to do with this issue since it is simply a wrapper package that exposes a configure-overrides.js file to allow developers to modify the webpack configurations managed by create-react-app.
The jest.config.ts or jest.config.js config file I created had no effect because create react app (CRA) will generate and use its own jest config file underneath the hood.
I discovered this by happenstance while researching on another issue. A comment by dstapleton92 on GitHub helped me draw this conclusion.
Create React App supports overriding SOME of the values via the "jest" property in package.json file. Upon inspecting the jest config factory function in CRA, testEnvironment property is hard coded to "jsdom" and the key is not exposed as part of the list of overridable properties.
This is why the attempts I made were not successful.

Import Polymer 2 components in Polymer 3

I am developing a web component using Polymer v3, and need to include some custom elements defined in legacy Polymer 2 components in the template HTML of my new component.
Since HTML imports are no longer supported in Polymer 3, what approach should I take to include them? If I was using Polymer 2 I could just add the following in my component's HTML file:
<link rel="import" href="../my-legacy-component.html">
I have tried adding the above link into the template HTML of my component, but it appears that doesn't work. I have also tried various import commands to reference the JS files inside the legacy component directly, but received various inscrutable JS errors so I'm not sure if that is the correct way to go either.
I can't believe there isn't a simple way to do this - would the Polymer team really introduce a new version of the library that is completely incompatible with all the components created using older versions?
Did you try to use polymer-modulizer?
Modulizer performs many different upgrade tasks, like:
Detects which .html files are used as HTML Imports and moves them to .js
Rewrites in HTML to import in JS.
Removes "module wrappers" - IIFEs that scopes your code.
Converts bower.json to package.json, using the corresponding packages on npm.
Converts "namespace references" to the proper JS module import, ie: Polymer.Async.timeOut to timeOut as imported from #polymer/polymer/lib/util/async.
Creates exports for values assigned to namespace referencs. ie, Foo.bar = {...} becomes export const bar = {...}
Rewrites namespace objects - an object with many members intended to be used as a module-like object, to JS modules.
Moves Polymer element templates from HTML into a JS template string.
Removes s if they only contained a template.
Moves other generic HTML in the document into a JS string and creates it when the module runs.
more on github
I have ran into the same problem with the module js-yaml earlier. I don't have enough reputation for a comment yet so I just write it down here.
Run this sudo npm install -g js-yaml -> This will install the missing package for the tool
Then at the root of your project, run modulizer --import-style name --out . -> This will convert your component from Polymer 2 to Polymer 3. The option --import-style name tells the tool to use package name instead of path. --out will make the tool writes those files to the directory.
After that, if no error prompts. Try to serve it with polymer serve --module-resolution=node -> Since we are using node modules now, we have to provide the --module-resolution=node option.

SSIS: How to programmatically reference child packages?

I have an SSIS package which in turn uses multiple child packages in it with execute package task.
I am trying to run the parent package prorammatically using code similar to the following:
Application app = new Application();
Package package = app.LoadPackage(ConfigurationManager.AppSettings["PackagePath"], null);
DTSExecResult results = package.Execute();
But when I execute the package I get an exception saying "There is no project to reference". How do I reference the child packages?
Are you using a ReferenceType of "Project Reference" in your parent SSIS package? If so, change it to "External Reference", and provide the file path of the package, as shown in this question.
I couldn't figure out how to do this using the file system path. But I was able to make it work after deploying the project with the parent and child packages to a SSIS Catalog by using code similar to whats explained in the following link.
http://muxtonmumbles.blogspot.com/2012/08/programmatically-executing-packages-in.html

Problems while trying to use components from another module in intellij idea AS3

i'am trying to use components from another module, but is not working.
Look what i have:
I have my project, its an app to convert files, and its working everything is ok. Now i want to change the interface... for that i cloned a github repository thats is a project with the components that i want to use, and imported it as a module. (should i import as a module or as a project?)
Everything great till now, but when i try to use the components from the module i cant find the classes or even the module...
Any suggestions?
You should add your imported sources as a new module (let's call it B), then you should add a dependency from your original module A to your module B in order to use its code.
See this page on how to configure module dependencies.