I am running my selenium java test suit in azure devops, after the execution i am able to see the result, but there is no attachment of failed screenshots. But when i run it in the local machine the cucumber report which is generating contains the screenshot.
Below is the code i have used to attach screenshot
#AfterStep
public void embedScreenshot(Scenario scenario) throws Exception {
if (scenario.isFailed()) {
try {
byte[] scrFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES);
scenario.embed(scrFile, "image/png");
} catch (WebDriverException somePlatformsDontSupportScreenshots) {
System.err.println(somePlatformsDontSupportScreenshots.getMessage());
}
}
}
Is there any plugin or anything else i can use to show the failed screenshot in the azure report?
I afraid there is not a plugin available to show the screenshot in azure report currently. For the screenshot is generated in the .html cucumber report. And azure devops doesnot support publishing generic HTML in build/release pipeline.
I guess the test result you saw is under the Tests tab of the azure pipeline build result page. And it is the xml format report which has been published to azure devops, not the html report which contains the screenshots.
There is feature request regarding this issue which has been submitted to microsoft develop team. You can go vote on it or create one of your own.
As a workaround, you can use the publish build artifacts task to publish the screenshots as artifacts of the pipeline.
steps:
- task: PublishBuildArtifacts#1
displayName: 'Publish Artifact: TestScreenshots'
inputs:
PathtoPublish: '$(System.defaultworkingdirectory)/target/home-page-html' #path to the test result folder(ie. html:target/home-page-html)
ArtifactName: TestScreenshots
Then you can get the screenshots from the build Summary page, See below:
If the screenshots reside in multiple test result folders. You can use copy files task to copy the screenshots to a place and then publish to build artifacts.
Environment
I'm currently trying to run JavaFX GUI tests via xvfb on multiple environments on Travis CI. I'm using Gradle to run these tests while using the TestFX and NestedRunner testing frameworks to write them. Before running the tests, export DISPLAY=:99.0 is called.
Context
There are times when the build succeeds and other times when it fails. However, I've noticed that Gradle outputs a single line that I can use to predict when the build will succeed or fail.
Before that line appears, one will see the following in the Travis CI log:
:richtextfx:compileJava
:richtextfx:processResources
:richtextfx:classes
:richtextfx:compileTestJava
:richtextfx:processTestResources
:richtextfx:testClasses
After that, one of two lines appears that predicts whether the build will succeed/fail:
on success: :richtextfx:testXlib: extension "RANDR" missing on display ":99.0".
on failure: :richtextfx:test
My Question
Why does Gradle change the test task to testXlib task? What are the inner mechanisms that handle this? And what does it all mean?
Gradle for sure does not do this. I've never heard of a task called testXlib and also the complete Gradle source does not contain this character sequence.
Either your build script does this, or some plugin you apply, or an init script that is applied by Travis CI.
Try to increase the logging level to debug and also add a call to tasks --all, maybe that will shed some light.
Yesterday I switched to IntelliJ IDEA from Eclipse.
I am using JRebel with WebSphere Server 7 as well.
Everything now seems to be working somewhat fine, except that when I modify a Java file, and hit save, IntelliJ does not re-compile the file, in order for JRebel to pick it up.
The Eclipse "Build Automatically" feature resolved this issue.
In IntelliJ IDEA, I have to hit CTRL+SHIFT+9 to re-compile the relevant class for JRebel to pick it up. If changes are done across two files, I have to do this on each and one of them and since IntelliJ uses the save all mechanism, its pretty hard to know what to recompile manually which I am not really interested in doing either.
Isn't there a way to make IntelliJ to do this on its own?
UPDATED
For IntelliJ IDEA 12+ releases we can build automatically the edited sources if we are using the external compiler option. The only thing needed is to check the option "Build project automatically", located under "Compiler" settings:
Also, if you would like to hot deploy, while the application is running or if you are using spring boot devtools you should enable the compiler.automake.allow.when.app.running from registry too. This will automatically compile your changes.
For versions greater than 2021.2, we need check 'Allow auto-make to start even id the development application is currently running' option:
For versions older than 2021.2:
Using Ctrl+Shift+A (or ⌘+Shift+A on Mac) type Registry once the registry windows is open, locate and enable compiler.automake.allow.when.app.running, see here:
For versions older than 12, you can use the *EclipseMode* plugin to make IDEA automatically compile the saved files.
For more tips see the "Migrating From Eclipse to IntelliJ IDEA" guide.
Please follow both steps:
1 - Enable Automake from the compiler
Press: ctrl + shift + A (For Mac ⌘ + shift + A)
Type: make project automatically
Hit: Enter
Enable Make Project automatically feature
2 - Enable Automake when the application is running
Press: ctrl + shift + A (For Mac ⌘ + shift + A)
Type: Registry
Find the key compiler.automake.allow.when.app.running and enable it or click the checkbox next to it
Note: Restart your application now :)
Note: This should also allow live reload with spring boot devtools.
WARNING
Eclipse Mode plug-in is obsolete and is not compatible with the recent IDEA 12+ builds. If you install it, IDE will hang on every file change and will respond extremely slow.
IntelliJ IDEA doesn't use automatic build, it detects errors on the fly, not via compiler. Similar to Eclipse mode will be available in IDEA 12:
Use Build | Make, it invokes the incremental make process that will compile only changed and dependent files (it's very fast).
There is also a FAQ entry that may help.
Update on the automatic make feature:
When run/debug configuration is running, Make project automatically has no effect. Classes on disk will change only on Build | Make. It's the core design decision as in our opinion class changes on disk should be always under user's control. Automatic make is not the copycat of Eclipse feature, it works differently and it's main purpose is to save time waiting for the classes to be ready when they are really needed (before running the app or tests). Automatic make doesn't replace the explicit compilation that you still need to trigger like in the case described in this question. If you are looking for different behavior, EclipseMode plug-in linked in the FAQ above would be a better choice.
You can keymap ctrl+s to save AND compile in one step. Go to the keymap settings and search for Compile.
There is actually no difference as both require 1 click:
Eclipse: manual Save, auto-compile.
IntelliJ: auto Save, manual compile.
Simplest solution is just to get used to it. Because when you spend most of your daytime in your IDE, then better have fast habits in one than slow habits in several of them.
I ended up recording a Macro to save and compile in one step, and keymap Ctrl+s to it.
I managed to solve this using macros.
I started recording a macro:
Click Edit - Macros - Start macro recording
Click File - Save All
Click Build - Make Project
Click Edit - Macros - Stop macro recording
Name it something useful like, "SaveAndMake".
Now just remove the Save all keybinding, and add the same keybinding to your macro!
So now, every time i save, it saves and makes a dirty compile, and jRebel now detects all changes correctly.
Please follow these steps carefully to enable it.
1) create Spring Boot project with SB V1.3 and add "Devtools" (1*) to dependencies
2) invoke Help->Find Action... and type "Registry", in the dialog search for "automake" and enable the entry "compiler.automake.allow.when.app.running", close dialog
3) enable background compilation in Settings->Build, Execution, Deployment->Compiler "Make project automatically"
4) open Spring Boot run config, you should get warning message if everything is configured correctly
5) Run your app, change your classes on-the-fly
Please report your experiences and problems as comments to this issue.
click here for more info
For folks using the new Intellij version and can't find compiler.automake.allow.when.app.running
https://youtrack.jetbrains.com/issue/IDEA-274903
Basically the option has now moved to Settings -> Advanced Settings -> Compiler (Check the Allow auto-make option)
The only thing that worked for me in my maven project that was affected by this is to add a "test-compile" goal to the run configuration of my unit tests. Incredibly clumsy solution, but it works.
Intellij fails quietly when it encounters compile problem in other module, and then automatic build is not performed. So check your Problems window
i had same issue and also a problem file icon in intellij, so i removed the .idea folder and re import project solved my issue.
For Intellij 2021 or later, you'll not find the registry entry
compiler.automake.allow.when.app.running
It has been moved to advanced settings as shown in the below screenshot
Source: https://youtrack.jetbrains.com/issue/IDEA-274903
I had the same issue.
I was using the "Power save mode", which prevents from compiling incrementally and showing compilation errors.
Use the Reformat and Compile plugin (inspired by the Save Actions plugin of Alexandre DuBreuil):
https://plugins.jetbrains.com/plugin/8231?pr=idea_ce
At the moment I am only offering a jar file, but this is the most important part of the code:
private final static Set<Document> documentsToProcess = new HashSet<Document>();
private static VirtualFile[] fileToCompile = VirtualFile.EMPTY_ARRAY;
// The plugin extends FileDocumentManagerAdapter.
// beforeDocumentSaving calls reformatAndCompile
private static void reformatAndCompile(
#NotNull final Project project,
#NotNull final Document document,
#NotNull final PsiFile psiFile) {
documentsToProcess.add(document);
if (storage.isEnabled(Action.compileFile) && isDocumentActive(project, document)) {
fileToCompile = isFileCompilable(project, psiFile.getVirtualFile());
}
ApplicationManager.getApplication().invokeLater(new Runnable() {
#Override
public void run() {
if (documentsToProcess.contains(document)) {
documentsToProcess.remove(document);
if (storage.isEnabled(Action.optimizeImports)
|| storage.isEnabled(Action.reformatCode)) {
CommandProcessor.getInstance().runUndoTransparentAction(new Runnable() {
#Override
public void run() {
if (storage.isEnabled(Action.optimizeImports)) {
new OptimizeImportsProcessor(project, psiFile)
.run();
}
if (storage.isEnabled(Action.reformatCode)) {
new ReformatCodeProcessor(
project,
psiFile,
null,
ChangeListManager
.getInstance(project)
.getChange(psiFile.getVirtualFile()) != null)
.run();
}
ApplicationManager.getApplication().runWriteAction(new Runnable() {
#Override
public void run() {
CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(psiFile);
}
});
}
});
}
}
if (fileToCompile.length > 0) {
if (documentsToProcess.isEmpty()) {
compileFile(project, fileToCompile);
fileToCompile = VirtualFile.EMPTY_ARRAY;
}
} else if (storage.isEnabled(Action.makeProject)) {
if (documentsToProcess.isEmpty()) {
makeProject(project);
}
} else {
saveFile(project, document, psiFile.getVirtualFile());
}
}
}, project.getDisposed());
}
private static void makeProject(#NotNull final Project project) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
#Override
public void run() {
CompilerManager.getInstance(project).make(null);
}
}, project.getDisposed());
}
private static void compileFile(
#NotNull final Project project,
#NotNull final VirtualFile[] files) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
#Override
public void run() {
CompilerManager.getInstance(project).compile(files, null);
}
}, project.getDisposed());
}
private static void saveFile(
#NotNull final Project project,
#NotNull final Document document,
#NotNull final VirtualFile file) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
#Override
public void run() {
final FileDocumentManager fileDocumentManager = FileDocumentManager.getInstance();
if (fileDocumentManager.isFileModified(file)) {
fileDocumentManager.saveDocument(document);
}
}
}, project.getDisposed());
}
Edit your Run/Debug Configuration so that Build option is selected before launching
After Build option is selected
The above solution worked for me while working on my JBehave test suite
It was not working for me due to having an unnecessary module in my project structure. The tests were executed using the other module, I suppose.
I don't know how it ended up like that but removing it solved the problem.
Make sure your Run/Debug settings are using the module you are building with the autosave.
E.g. : see the module in
You can change the modules in Project Structure - Modules
I had the same issue. I think it would be appropriate to check whether your class can be compiled or not. Click recompile (Ctrl+Shift+F9 by default). If its not working then you have to investigate why it isn't compiling.
In my case the code wasn't autocompiling because there were hidden errors with compilation (they weren't shown in logs anywhere and maven clean-install was working). The rootcause was incorrect Project Structure -> Modules configuration, so Intellij Idea wasn't able to build it according to this configuration.
I was getting error: some jars are not in classpath.So I just delete the corrupted jar and perrform below steps
1.Project > Setting>Build,Execution,Deployment>Compiler>check build project automatically
2.CTRL+SHIFT+A find/search **registry** --Check for below param
compiler.automake.allow.when.app.running
compiler.automake.trigger.delay=500---According to ur requirement
3.Add devtool in pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
4.Build ,If found any probelm while building ,saying some jar in not in class path.Just delete the corrupted jar
and re-build the project angain after sync with maven lib
Not enough points to comment on an existing answer, but similar to some people above, I wound up just adding a macro & keymap to Organize Imports / Format / SaveAll / FastReload(F9) / Synchronize.
The synchronize is added as it seems to be the only way I can also see updates in resources modified by external build tools / watchers (i.e., webpack).
The process is slower than eclipse - and for the external file refresh often have to run the command multiple times - but suppose I can live with it.
How do I set the main Java type in Eclipse (latest)?
I have a main client, and then a bunch of unit tests that exercise various code paths and conditions. Normally I'd like to debug or execute the unit tests depending on the feature I'm developing. However, when the boss shows up, I'd like to quickly run my main driver class without hunting and pecking for the .java file, then hitting debug.
Is there an easy way to set/change the main type? How do folks normally handle running unit tests in Eclipse?
Click on the arrow in the run/debug icon and select Organize Favorites at the bottom and set favorites for anything you don't want to fumble around for later.
For unit tests, I just run them like anything else in Eclipse. I also include a test target in my Ant scripts.
For unit tests :
You can make test suite so to bundle them by feature. This way you just need to run the test suite related to your feature.
Having several launch configuration :
Just go Run Configuration... or Debug Configuration ... from Run menu and create the configuration you want. Next time you'll want to Run them go again to that menu select it and click Run/Debug;
To gain time you can go to Keys configuration and set at shortcut to "Run..." or "Debug..." submenu.
Right click on your test folder and "Run as ... -> JUnit test"?
From Run > Run Configuration... Create a new Run Configuration for the type of java application you have and the options let you specify the main class.
And these configurations will be available in the Run As button dropdown.